Skip to content

fix: recover orphaned Anthropic native web searches - #1645

Merged
1jehuang merged 5 commits into
1jehuang:masterfrom
Soham-o:fix/1638-orphaned-native-web-search
Oct 4, 2026
Merged

1jehuang merged 5 commits into
1jehuang:masterfrom
Soham-o:fix/1638-orphaned-native-web-search

Conversation

@Soham-o

@Soham-o Soham-o commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • repair persisted Anthropic server_tool_use blocks that have no matching web_search_tool_result
  • drop orphaned native search blocks from completed history instead of inventing a server response
  • preserve a final unmatched server-tool block so legitimate pause_turn resume behavior is unchanged
  • drop unmatched native search results and add focused regression coverage

Fixes #1638.

Validation

  • regression tests cover orphaned call removal, orphaned result removal, pause-turn preservation, and valid pair replay
  • branch is based directly on current master

@Soham-o
Soham-o marked this pull request as ready for review October 2, 2026 14:43
@greptile-apps

greptile-apps Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

[Medium risk] Repairs orphaned web search blocks in message history.

No blocking issues remain; the outstanding documentation typo does not block merging.

Findings

  1. P2 Remove the stray doc marker ▶
Fix with agent prompt
### Issue 1
crates/jcode-provider-anthropic/src/lib.rs:undefined-469
The mid-sentence `///` renders literally as “answered/// exactly” in the function documentation, making the description harder to read. This documentation issue does not block merging.

```suggestion
/// Remove duplicate tool_result blocks so each tool_use_id is answered
/// exactly once, preferring real output over a synthetic placeholder.
```

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Summary

The PR drops unmatched Anthropic web-search calls from completed history while preserving a final unmatched call for turn resumption. No new findings are reported.

Reviews (2) · Last reviewed commit: "test(anthropic): cover dropped orphaned ..."

Comment thread crates/jcode-provider-anthropic/src/lib.rs Outdated
repaired
}

/// Remove duplicate tool_result blocks so each tool_use_id is answered/// exactly once, preferring real output over a synthetic placeholder.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Remove the stray doc marker

The mid-sentence /// renders literally as “answered/// exactly” in the function documentation, making the description harder to read. This documentation issue does not block merging.

Suggested change
/// Remove duplicate tool_result blocks so each tool_use_id is answered/// exactly once, preferring real output over a synthetic placeholder.
/// Remove duplicate tool_result blocks so each tool_use_id is answered
/// exactly once, preferring real output over a synthetic placeholder.
Artifacts

Rustdoc comparison script

  • This authored script extracts the comment from the cited source, renders it with rustdoc, and reports the resulting docblock text.

Rustdoc output with corrected wording

  • Running the script with only the stray marker removed rendered “answered exactly”, establishing the comparison baseline.

Rustdoc output with source wording

  • Running the script against the comment as written rendered “answered/// exactly”, confirming the documentation defect.

View artifacts

T-Rex Ran code and verified through T-Rex

Prompt To Fix With AI
This is a comment left during a code review.
Path: crates/jcode-provider-anthropic/src/lib.rs
Line: 481

Comment:
**Remove the stray doc marker**

The mid-sentence `///` renders literally as “answered/// exactly” in the function documentation, making the description harder to read. This documentation issue does not block merging.

```suggestion
/// Remove duplicate tool_result blocks so each tool_use_id is answered
/// exactly once, preferring real output over a synthetic placeholder.
```

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

@1jehuang
1jehuang merged commit bdf053d into 1jehuang:master Oct 4, 2026
1 check passed
@1jehuang

1jehuang commented Oct 4, 2026

Copy link
Copy Markdown
Owner

Merged into master, thanks! Crate tests and clippy pass locally on the merged result.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Orphaned web_search server_tool_use in history causes permanent 400 (session unrecoverable)

2 participants