Skip to content

Repair partial text tool-call recovery#4445

Merged
asim merged 1 commit into
masterfrom
codex/increment-4444
Jul 9, 2026
Merged

Repair partial text tool-call recovery#4445
asim merged 1 commit into
masterfrom
codex/increment-4444

Conversation

@asim

@asim asim commented Jul 9, 2026

Copy link
Copy Markdown
Member

Summary:

  • Detect incomplete XML-style text tool-call markup and retry with scoped repair guidance instead of treating the turn as complete.
  • Add regression coverage for a provider response that stops at an opening <tool_call> tag before succeeding on retry.

Testing:

@asim asim added the codex label Jul 9, 2026
Copilot AI review requested due to automatic review settings July 9, 2026 07:59
@asim asim merged commit 4150e8d into master Jul 9, 2026
11 checks passed

Copilot AI 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.

Pull request overview

This PR improves the agent’s resilience to provider responses that begin XML-style text tool-call markup but truncate before emitting a complete tool call, by detecting the partial markup and retrying with targeted repair guidance (plus adding a regression test for this scenario).

Changes:

  • Add detection for incomplete <tool_call …> openings and extract the intended tool name when possible.
  • In askLocked, if no tool calls were executed but a partial text tool call was detected, retry with a scoped prompt instructing the model to emit one complete valid tool call.
  • Add regression coverage for a provider response that stops at an opening <tool_call> tag and succeeds on retry.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
agent/text_tool_calls.go Adds partial <tool_call> opener detection helper and supporting regex.
agent/agent.go Uses the partial tool-call detection to trigger a repair/retry turn when no tool executed.
agent/conformance_test.go Adds regression test ensuring partial text tool-call markup triggers a repair retry and executes the tool.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread agent/text_tool_calls.go
Comment on lines +123 to +144
openMatches := openingTaggedToolCall.FindAllStringSubmatchIndex(text, -1)
if len(openMatches) == 0 {
return ""
}
closedMatches := singleTaggedToolCall.FindAllStringSubmatchIndex(text, -1)
for _, open := range openMatches {
closed := false
for _, match := range closedMatches {
if match[0] == open[0] {
closed = true
break
}
}
if closed {
continue
}
tag := text[open[2]:open[3]]
name := taggedToolName(tag)
if canonical := allowed[name]; canonical != "" {
return canonical
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants