Skip to content
This repository was archived by the owner on May 13, 2026. It is now read-only.

Drop nameless assistant tool_calls and emit parsed tool_calls atomically in sieve - #81

Merged
CJackHwang merged 12 commits into
devfrom
codex/linear-mention-cja-8
Mar 7, 2026
Merged

CJackHwang merged 12 commits into
devfrom
codex/linear-mention-cja-8

Conversation

@CJackHwang

Copy link
Copy Markdown
Owner

Motivation

  • Prevent creating ambiguous or misleading tool-history entries when assistant tool call records lack a name.
  • Ensure parsed tool_calls are emitted as events in the same processing tick once a complete payload is detected to avoid leaking partial JSON as text and to keep streaming behavior deterministic.

Description

  • Update formatAssistantToolCallsForPrompt to skip (drop) assistant tool_calls entries that do not resolve to a non-empty name instead of inserting an unknown name into the prompt history.
  • Add TestNormalizeOpenAIMessagesForPrompt_AssistantToolCallsMissingNameAreDropped to validate that nameless assistant tool_calls are dropped.
  • Refactor processToolSieveChunk in internal/js/helpers/stream-tool-sieve/sieve.js to emit pending tool_calls events immediately within the processing loop and continue processing, clearing pendingToolRaw and pendingToolCalls to avoid treating complete tool payloads as leaked text.
  • Extend and adjust JavaScript tests in tests/node/stream-tool-sieve.test.js to assert that tool_calls are emitted in the same chunk/tick when payloads become complete and that late-key convergence produces a tool_calls event while avoiding leaking the JSON marker text.

Testing

  • Ran Go unit tests for message normalization including TestNormalizeOpenAIMessagesForPrompt_AssistantToolCallsMissingNameAreDropped and existing message-normalize tests, and they passed.
  • Ran Node unit tests for the sieve behavior (tests/node/stream-tool-sieve.test.js) via the test suite and verified the new and updated tests passed.

Codex Task

Merge pull request #72 from CJackHwang/codex/review-changes-to-test-account-logic

Normalize mobile login numbers, skip completion flow for session-only account tests, and add tests
Merge pull request #74 from CJackHwang/codex/fix-toolcall-whitelist-issue

Recognize and emit executable tool_calls in mixed prose streams; normalize roles and loosen tool-name matching
Merge pull request #79 from CJackHwang/codex/analyze-and-optimize-issue-#77

fix: 避免 assistant.content=nil 注入 "null" 导致工具历史混杂
@vercel

vercel Bot commented Mar 7, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
ds2api Ready Ready Preview, Comment Mar 7, 2026 9:46am

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: af68d21095

ℹ️ 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".

Comment on lines +120 to +123
detected := util.ParseToolCalls(s.text.String(), s.toolNames)
if len(detected) > 0 {
s.finalize("tool_use")
return streamengine.ParsedDecision{

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Delay tool-call stop until fenced code context is complete

In onParsed, tool-mode streaming now calls ParseToolCalls on every partial chunk and stops immediately when it sees a parseable call. This can misfire on chunked fenced examples: if a chunk contains `````json\n{"tool_calls":...}``` before the closing fence arrives in a later chunk, stripFencedCodeBlocks cannot remove it yet and the parser treats it as a real tool call, causing an early `tool_use` stop and truncating normal assistant output.

Useful? React with 👍 / 👎.

Comment thread internal/util/toolcalls_parse.go Outdated
}

func parseAntmlFunctionCallStyle(text string) (ParsedToolCall, bool) {
m := antmlFunctionCallPattern.FindStringSubmatch(text)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Parse all ANTML function_call entries, not only the first

parseAntmlFunctionCallStyle uses FindStringSubmatch, so it captures only the first <antml:function_call> in an <antml:function_calls> payload. As a result, multi-call ANTML outputs silently drop later tool calls, which means only a subset of requested tools is executed and downstream results can be incomplete.

Useful? React with 👍 / 👎.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Credits must be used to enable repository wide code reviews.

@CJackHwang
CJackHwang changed the base branch from main to dev March 7, 2026 09:31
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Credits must be used to enable repository wide code reviews.

@CJackHwang
CJackHwang merged commit 5484d6e into dev Mar 7, 2026
3 checks passed
@CJackHwang
CJackHwang deleted the codex/linear-mention-cja-8 branch March 7, 2026 15:16
CJackHwang added a commit that referenced this pull request Mar 7, 2026
Merge pull request #81 from CJackHwang/codex/linear-mention-cja-8

Drop nameless assistant tool_calls and emit parsed tool_calls atomically in sieve

This branch was successfully deployed

1 active deployment
Preview — 0ce3fd22 Deployed Mar 7, 2026 by vercel[bot]
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] 目前工具调用存在一些格式问题导致系统无法识别 [Bug] cc的工具调用不正常

1 participant