fix(skills): record tool call outcomes in native tool path#1462
Merged
fix(skills): record tool call outcomes in native tool path#1462
Conversation
`handle_native_tool_calls` never called `record_skill_outcomes()`, so Wilson score received no signal from actual tool execution when using providers with native tool_use support (Claude, OpenAI). Add `record_skill_outcomes` calls after each tool result in the native path, mirroring the legacy `handle_tool_result` behavior: - success output → "success" outcome - `[error]`/`[exit code` output → "tool_failure" + attempt_self_reflection - executor error (`Err(e)`) → "tool_failure" Also add 5 regression tests covering all branches. Fixes #1436
Apply ContentSource sanitization to tool output before passing it to attempt_self_reflection(), matching the legacy error path behavior. Also document the known limitation that a self-reflection early return from handle_native_tool_calls drops remaining batch results. Update config snapshot after LSP defaults removal in main.
The lsp section was incorrectly removed from the snapshot during branch sync. Config::default() with --features full still includes it.
fd6de07 to
76024e2
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
handle_native_tool_callsnever calledrecord_skill_outcomes(), so Wilson score re-ranking received zero signal from actual tool execution when using providers with nativetool_usesupport (Claude, OpenAI, OpenAI-compatible).Only the legacy text-extraction path called
record_skill_outcomes(viahandle_tool_result), meaning skill rankings were based solely on explicit user feedback corrections — never on whether tool calls actually succeeded or failed.Root Cause
handle_native_tool_calls(tool_execution.rs) processes tool results and sends outputs back to the LLM, but contained no calls torecord_skill_outcomes. The legacyhandle_tool_resultpath had these calls at lines ~638, 644, 659, 736.Fix
Added
record_skill_outcomescalls in the results loop ofhandle_native_tool_calls, after thematch tool_resultblock, mirroring legacy behavior:Ok(Some(out))— success output"success"Ok(Some(out))—[error]/[exit code"tool_failure"+attempt_self_reflectionOk(Some(out))— empty output"success"Ok(None)"success"(via"(no output)"→ else branch)Err(e)"tool_failure"attempt_self_reflectionis included on the native failure path (matching legacy) — at the insertion pointpersist_message/push_messagehave not yet been called, soreturn Ok(())is safe.Tests
5 regression tests added covering all branches:
native_tool_success_outcome_does_not_panicnative_tool_error_output_does_not_panicnative_tool_exit_code_output_does_not_panicnative_tool_executor_error_does_not_panicnative_tool_no_active_skills_does_not_panicFixes #1436