refactor(tools): schemars-based tool registry, invocation hints#267
Merged
refactor(tools): schemars-based tool registry, invocation hints#267
Conversation
…chema - Add schemars 1.2 for compile-time JSON Schema generation - Replace ParamDef/ParamType with schemars::Schema in ToolDef - Add InvocationHint enum (FencedBlock/ToolCall) so LLM knows invocation format - Delete builtin_tools() duplication, each executor owns its tool_definitions() - Add #[derive(JsonSchema)] to ScrapeInstruction, BashParams, file param structs - ToolRegistry::from_definitions() replaces hardcoded new() - format_for_prompt() renders invocation instructions and schema params - Agent builds registry from executor definitions (single source of truth)
- Fix Option<T> type rendering in format_schema_params (extract non-null type from schemars array format) - Remove dead format_for_prompt() method, use filtered variant everywhere - Make param structs pub(crate) to eliminate test duplication - Add negative assertion for optional extract param in scrape tests - Add schema-only context comments on param structs
Codecov Report❌ Patch coverage is
@@ Coverage Diff @@
## main #267 +/- ##
==========================================
- Coverage 81.23% 81.15% -0.08%
==========================================
Files 83 83
Lines 24614 24552 -62
==========================================
- Hits 19994 19924 -70
- Misses 4620 4628 +8
🚀 New features to boost your workflow:
|
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.
Summary
ParamDef/ParamTypewithschemars1.2#[derive(JsonSchema)]on tool parameter structsInvocationHintenum (FencedBlock("bash")/FencedBlock("scrape")/ToolCall) toToolDefso LLM knows exact invocation formatbuiltin_tools()duplication — each executor owns itstool_definitions()(single source of truth)ToolRegistry::from_definitions()replaces hardcodednew()format_for_prompt()renders invocation instructions and schema-derived parameter docsweb_scrapemissing params (select,extract,limit) — now auto-derived fromScrapeInstructionTest plan