fix(toolcall): fix deepseek function calling bug and add json repair#92
fix(toolcall): fix deepseek function calling bug and add json repair#92CJackHwang merged 5 commits intoCJackHwang:devfrom
Conversation
Merge pull request CJackHwang#89 from CJackHwang/codex/review-changes-in-pull-request-#88 Support text-kv `function.name`/`function.arguments` fallback and looser name matching
- Fix: Expand stream sieve keywords to support function.name: and [TOOL_CALL_HISTORY] - Fix: Add repairInvalidJSONBackslashes to handle unescaped backslashes in Windows paths - Sync: Update JS stream sieve to match Go implementation - Test: Add unit tests for backslash repair and deepseek format parsing - Tool: Move repair json test tool to tests/repair_json_tool.go
|
@valkryhx is attempting to deploy a commit to the cjack's projects Team on Vercel. A member of the Team first needs to authorize it. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7318d1f4a8
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| return -1 | ||
| } | ||
| lower := strings.ToLower(s) | ||
| keywords := []string{"tool_calls", "function.name:", "[tool_call_history]"} |
There was a problem hiding this comment.
Parse newly-detected DeepSeek markers before capturing stream
Adding function.name: and [TOOL_CALL_HISTORY] to the start detector makes the sieve enter capture mode for DeepSeek text-KV outputs, but this capture path is still parsed only via tool_calls JSON in consumeToolCapture. In that scenario ready stays false on each chunk, so streaming content is withheld until flush and no tool call is emitted, which regresses live responses whenever these markers appear.
Useful? React with 👍 / 👎.
| if i+1 < len(runes) { | ||
| next := runes[i+1] | ||
| switch next { | ||
| case '"', '\\', '/', 'b', 'f', 'n', 'r', 't': |
There was a problem hiding this comment.
Escape backslash-n/t/r sequences in repaired path arguments
The repair routine currently preserves escapes like \n, \t, and \r as valid JSON escapes, which breaks the Windows-path recovery this change introduces: inputs such as {"path":"C:\new\tmp"} still deserialize with newline/tab characters instead of literal backslashes. This silently corrupts tool arguments after json.Unmarshal rather than returning the original raw payload.
Useful? React with 👍 / 👎.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
@valkryhx You can look at the review results of codex and see if you can solve it. Thank you. |
- Upgrade missingArrayBracketsPattern regex to support single-level nested {} objects
- This fixes DeepSeek's list hallucination where tool call JSON objects contain nested fields like {"input": {"q": "value"}}
- Add comprehensive test cases covering 2-5 nested objects, mixed nested/primitive fields, and real DeepSeek 8-queen output patterns
- Add RepairLooseJSON function to repair unquoted keys and missing array brackets
Fixes: DeepSeek tool call parsing with nested JSON objects
…ds and safety limits - Add support for multiple keywords: tool_calls, function.name:, [tool_call_history] - Add OOM protection with search limits in extractToolCallObjects - Add max scan length limit in extractJSONObject to prevent OOM on unclosed objects - Update tool_sieve to handle more tool call patterns - Add loose JSON repair in parseToolCallPayload for better error recovery This improves DeepSeek tool call parsing robustness.
- Add targeted test commands to TESTING.md for debugging tool call issues - Add quick test commands reference in README.md - Document specific test cases for DeepSeek tool call parsing
Fix: Expand stream sieve keywords to support function.name: and [TOOL_CALL_HISTORY]
Fix: Add repairInvalidJSONBackslashes to handle unescaped backslashes in Windows paths
Sync: Update JS stream sieve to match Go implementation
Test: Add unit tests for backslash repair and deepseek format parsing
Tool: Move repair json test tool to tests/repair_json_tool.go