Run failed: Invalid context structure: {......JSON STRUCTURED DATA.....} #6017

Closed
opened 2026-02-21 18:13:42 -05:00 by yindo · 1 comment
Owner

Originally created by @Namec999 on GitHub (Oct 10, 2024).

Self Checks

  • I have searched for existing issues search for existing issues, including closed ones.
  • I confirm that I am using English to submit report (我已阅读并同意 Language Policy).
  • [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:)
  • Please do not modify this template :) and fill in all the required fields.

Provide a description of requested docs changes

Hello,

my tool output is JSON and i can store it in a variable OK

but when the JSON structured data is passed as a context to an LLM, i got this error in the chat :

Run failed: Invalid context structure: {'id': 17498, 'Registration': '0457557756', 'Code': 'CB023'}

Originally created by @Namec999 on GitHub (Oct 10, 2024). ### Self Checks - [X] I have searched for existing issues [search for existing issues](https://github.com/langgenius/dify/issues), including closed ones. - [X] I confirm that I am using English to submit report (我已阅读并同意 [Language Policy](https://github.com/langgenius/dify/issues/1542)). - [X] [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:) - [X] Please do not modify this template :) and fill in all the required fields. ### Provide a description of requested docs changes Hello, my tool output is JSON and i can store it in a variable OK but when the JSON structured data is passed as a context to an LLM, i got this error in the chat : Run failed: Invalid context structure: {'id': 17498, 'Registration': '0457557756', 'Code': 'CB023'}
yindo added the 🐞 bug label 2026-02-21 18:13:42 -05:00
yindo closed this issue 2026-02-21 18:13:42 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Oct 10, 2024):

I found a similar closed issue regarding the "Invalid context structure" error. The solution involves ensuring that your context data is structured correctly. Each item in your context list must include a 'content' key. This error often occurs due to stricter validation in recent versions [1].

To resolve this, make sure your JSON data adheres to the expected structure. Here are some steps:

  1. Ensure Each Item Has a 'Content' Key: Your context should be a list where each item is a dictionary containing a 'content' key.

  2. Validate Against JSON Schema: Make sure your JSON data matches the defined JSON Schema. Enable strict mode and disable additional properties if necessary [2].

  3. Use Supported Models: Ensure you're using a model that supports JSON Schema functionality.

By following these guidelines, you should be able to resolve the error.

To continue talking to Dosu, mention @dosu.

@dosubot[bot] commented on GitHub (Oct 10, 2024): <!-- Answer --> I found a similar closed issue regarding the "Invalid context structure" error. The solution involves ensuring that your context data is structured correctly. Each item in your context list must include a 'content' key. This error often occurs due to stricter validation in recent versions <sup>[[1]](https://github.com/langgenius/dify/issues/8095)</sup>. To resolve this, make sure your JSON data adheres to the expected structure. Here are some steps: 1. **Ensure Each Item Has a 'Content' Key**: Your context should be a list where each item is a dictionary containing a 'content' key. 2. **Validate Against JSON Schema**: Make sure your JSON data matches the defined JSON Schema. Enable strict mode and disable additional properties if necessary <sup>[[2]](https://github.com/langgenius/dify-docs/blob/main/en/learn-more/how-to-use-json-schema-in-dify.md)</sup>. 3. **Use Supported Models**: Ensure you're using a model that supports JSON Schema functionality. By following these guidelines, you should be able to resolve the error. <!-- Dosu Comment Footer --> *To continue talking to [Dosu](https://dosu.dev), mention @dosu.*
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#6017