feat: type coercion for string-typed tool params#62
Open
Simon-Free wants to merge 4 commits intoSafeRL-Lab:mainfrom
Open
feat: type coercion for string-typed tool params#62Simon-Free wants to merge 4 commits intoSafeRL-Lab:mainfrom
Simon-Free wants to merge 4 commits intoSafeRL-Lab:mainfrom
Conversation
Split _coerce_params (20 lines, nested try/except chain) into:
- a small orchestrator that walks params and delegates,
- four single-purpose coercers (_coerce_int / _coerce_float /
_coerce_bool / _coerce_json) dispatched through a _COERCERS map.
Each catching coercer still returns the original string on failure -- but
the intent is now explicit via a comment ("tool handler reports the real
type mismatch"), and the bare `except: pass` silent-pass pattern is gone.
Also fix test_scheduling_params_stripped which called execute_tool without
the required config arg; it has been failing since the pr4 branch landed.
Add tests/test_tool_scheduling_e2e.py that drives agent.run with a
mocked LLM:
- assert every schema sent to the stream carries tool_call_alias +
depends_on (proof the schema injection path is wired through the full
agent loop, not just a unit helper);
- register a "receiver" tool, let the LLM emit a tool_call with
scheduling params + one real param, assert the scheduling params are
gone and the real param reaches the handler.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.
feat: type coercion for string-typed tool params
Standalone type coercion module extracted from PR #50.
What it does:
Bug fixes vs original PR #50 bundling:
Tests: 17 unit tests covering all type coercions, edge cases, and both schema styles.
See also: PR #50 (scheduling + ID uniqueness)