fix(session): distinguish malformed known-tool input from unknown tools#25788
fix(session): distinguish malformed known-tool input from unknown tools#25788johanhallberg wants to merge 1 commit into
Conversation
|
Thanks for your contribution! This PR doesn't have a linked issue. All PRs must reference an existing issue. Please:
See CONTRIBUTING.md for details. |
|
The following comment was made by an LLM, it may be inaccurate: Based on my search, I found two potentially related PRs:
These PRs share similar concerns around tool-call handling, error classification, and session management, though they may be addressing different aspects of the problem. |
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
|
Thanks — I checked the related issues. This PR is intentionally narrow. It does not try to solve all malformed/truncated tool-call recovery behavior. It only distinguishes the repair result for two cases that currently collapse into the same
This should complement, not replace, the broader recovery work discussed in #18108, #15906, and #21900. The goal is to give downstream handling and users a clearer error classification without changing the existing lowercase tool-name repair behavior. |
|
Automated PR Cleanup Thank you for contributing to opencode. Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions. This PR was closed because it matched the following cleanup criteria:
PRs created within the last month are not affected by this cleanup. If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate. Thanks again for taking the time to contribute. |
Issue for this PR
Fixes #25789
Type of change
What does this PR do?
This PR distinguishes two different tool-call repair failure cases:
Previously, both cases were routed through the
invalidtool in a way that made malformed input for a valid tool look like a generic invalid/unknown tool call.The change extracts the classification logic into
repairToolCallFailure()and keeps the existing lowercase tool-name repair behavior.The
invalidtool now accepts optionaltypeandhintfields so callers can distinguish:unknown_toolknown_tool_invalid_inputThis gives users and maintainers clearer feedback when a valid tool was selected but its input could not be parsed.
How did you verify your code works?
Tested locally with:
Results:
test/session/llm.test.ts: 17 pass, 0 failtest/tool/parameters.test.ts: 54 pass, 0 failbun run typecheck: passI also ran a manual smoke test with a patched source build:
writetool usage still worksunknown_toolScreenshots / recordings
N/A — this is not a UI change.
Checklist