Merge pull request #104 from CJackHwang/codex/revert-to-commit-efb484b Restore tool-call parsing and repair logic; remove accidental split files#105
Conversation
…-audit-pr fix: unblock PR #101 line gate and improve PoW/token retry handling
Restore tool-call parsing and repair logic; remove accidental split files
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e49d9d33e2
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
internal/util/toolcalls_parse.go
Outdated
| if err := json.Unmarshal([]byte(raw), &parsed); err == nil && parsed != nil { | ||
| return parsed | ||
| } |
There was a problem hiding this comment.
Re-run path-safe repair after successful JSON unmarshal
In parseToolCallInput, string arguments return immediately on the first successful json.Unmarshal. That allows payloads such as {"path":"D:\tmp\a.txt"} to pass with \t/\n/\r decoded into control characters, silently corrupting Windows-style paths before tool execution. This is a regression from the prior path-context safeguard and can make file/tool operations target the wrong path while still looking like a successful parse.
Useful? React with 👍 / 👎.
| // E.g., "key": {"a": 1}, {"b": 2} -> "key": [{"a": 1}, {"b": 2}] | ||
| // NOTE: The pattern uses (?:[^{}]|\{[^{}]*\})* to support single-level nested {} objects, | ||
| // which handles cases like {"content": "x", "input": {"q": "y"}} | ||
| var missingArrayBracketsPattern = regexp.MustCompile(`(:\s*)(\{(?:[^{}]|\{[^{}]*\})*\}(?:\s*,\s*\{(?:[^{}]|\{[^{}]*\})*\})+)`) |
There was a problem hiding this comment.
Restore deep-nesting bracket repair for loose JSON object lists
The missing-array repair now relies solely on missingArrayBracketsPattern, which only supports one nested object level. Deeply nested hallucinated lists (for example items containing {"meta":{"a":{"b":1}}}) are no longer repaired into arrays, so downstream parsing drops otherwise recoverable tool calls. The previous scanner-based path handled deeper nesting, so this change regresses robustness on realistic malformed model outputs.
Useful? React with 👍 / 👎.
💻 变更类型 | Change Type
🔀 变更说明 | Description of Change
优化 激进模式
📝 补充信息 | Additional Information