-
Notifications
You must be signed in to change notification settings - Fork 831
fix: use json.loads(strict=False) for all LLM output parsing paths #1580
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -69,7 +69,7 @@ def is_empty(self) -> bool: | |||||||||||||||||||||
| line = line.strip() | ||||||||||||||||||||||
| if not line: | ||||||||||||||||||||||
| continue | ||||||||||||||||||||||
| role = json.loads(line).get("role") | ||||||||||||||||||||||
| role = json.loads(line, strict=False).get("role") | ||||||||||||||||||||||
|
||||||||||||||||||||||
| role = json.loads(line, strict=False).get("role") | |
| try: | |
| record = json.loads(line, strict=False) | |
| except (json.JSONDecodeError, ValueError, TypeError): | |
| logger.warning( | |
| "Skipping malformed JSON line in context file {file}:", | |
| file=self.context_file, | |
| ) | |
| continue | |
| role = record.get("role") |
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -70,7 +70,7 @@ def _format_tool_call(tool_call: ToolCall) -> Panel: | |||||||||
| """Format a tool call.""" | ||||||||||
| args = tool_call.function.arguments or "{}" | ||||||||||
| try: | ||||||||||
| args_formatted = json.dumps(json.loads(args), indent=2) | ||||||||||
| args_formatted = json.dumps(json.loads(args, strict=False), indent=2) | ||||||||||
| args_syntax = Syntax(args_formatted, "json", theme="monokai", padding=(0, 1)) | ||||||||||
| except json.JSONDecodeError: | ||||||||||
| args_syntax = Text(args, style="red") | ||||||||||
|
Comment on lines
75
to
76
|
||||||||||
| except json.JSONDecodeError: | |
| args_syntax = Text(args, style="red") | |
| except (json.JSONDecodeError, TypeError): | |
| args_syntax = Text(str(args), style="red") |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -55,7 +55,7 @@ def _extract_tool_call_hint(args_json: str) -> str: | |||||
| short string value. Returns ``""`` when nothing useful is found. | ||||||
| """ | ||||||
| try: | ||||||
| parsed: object = json.loads(args_json) | ||||||
| parsed: object = json.loads(args_json, strict=False) | ||||||
| except (json.JSONDecodeError, TypeError): | ||||||
| return "" | ||||||
| if not isinstance(parsed, dict): | ||||||
|
|
@@ -104,7 +104,8 @@ def _format_tool_call_md(tool_call: ToolCall) -> str: | |||||
| title += f" (`{hint}`)" | ||||||
|
|
||||||
| try: | ||||||
| args_formatted = json.dumps(json.loads(args_raw), indent=2, ensure_ascii=False) | ||||||
| parsed = json.loads(args_raw, strict=False) | ||||||
| args_formatted = json.dumps(parsed, indent=2, ensure_ascii=False) | ||||||
| except json.JSONDecodeError: | ||||||
|
||||||
| except json.JSONDecodeError: | |
| except (json.JSONDecodeError, TypeError): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🟡 Manual edit to auto-generated English changelog violates docs/AGENTS.md rule
The
docs/AGENTS.mdrule states: "The English changelog (docs/en/release-notes/changelog.md) is auto-generated from the rootCHANGELOG.md. Do not edit it manually." This PR directly adds a new entry todocs/en/release-notes/changelog.md, which should instead be generated by runningnpm run syncfrom thedocs/directory after editing the rootCHANGELOG.md. The content is identical to what the sync script would produce, so there is no functional impact, but it violates the stated workflow.Prompt for agents
Was this helpful? React with 👍 or 👎 to provide feedback.