@@ -123,13 +123,14 @@ async def get(self, context: ConversationContext) -> AssistantConversationInspec
123123 if not document :
124124 return AssistantConversationInspectorStateDataModel (data = {"content" : "No current document." })
125125
126+ is_readonly = await self ._controller .is_read_only (context )
127+
126128 return AssistantConversationInspectorStateDataModel (
127- data = document .model_dump (mode = "json" ),
128- json_schema = document .model_json_schema (),
129- ui_schema = _get_document_editor_ui_schema (
130- await self ._controller .is_read_only (context ),
131- await self ._controller .list_documents (context ),
132- ),
129+ data = {
130+ "markdown_content" : document .content ,
131+ "filename" : document .filename ,
132+ "readonly" : is_readonly ,
133+ }
133134 )
134135
135136 async def set (
@@ -142,13 +143,18 @@ async def set(
142143 if await self ._controller .is_read_only (context ):
143144 return
144145
145- try :
146- model = DocumentFileStateModel .model_validate (data )
147- except ValidationError :
148- logger .exception ("invalid data for DocumentFileStateModel" )
149- return
150-
151- await self ._controller .write_active_document (context , model .content )
146+ # The data comes in with 'markdown_content' but our model expects 'content'
147+ if "markdown_content" in data :
148+ content = data ["markdown_content" ]
149+ # If filename is present but we don't need to modify it, we can just get the content
150+ await self ._controller .write_active_document (context , content )
151+ else :
152+ try :
153+ model = DocumentFileStateModel .model_validate (data )
154+ await self ._controller .write_active_document (context , model .content )
155+ except ValidationError :
156+ logger .exception ("invalid data for DocumentFileStateModel" )
157+ return
152158
153159
154160class ReadonlyDocumentFileStateInspector :
@@ -189,7 +195,11 @@ async def get(self, context: ConversationContext) -> AssistantConversationInspec
189195 return AssistantConversationInspectorStateDataModel (data = {"content" : "No current document." })
190196
191197 return AssistantConversationInspectorStateDataModel (
192- data = {"content" : f"```markdown\n _Filename: { document .filename } _\n \n { document .content } \n ```" }
198+ data = {
199+ "markdown_content" : document .content ,
200+ "filename" : document .filename ,
201+ "readonly" : True , # Always read-only for this inspector
202+ },
193203 )
194204
195205
0 commit comments