fix(repl): resolve Tool.description to string in /context schema payload - #163
Merged
Conversation
Tool.description is a Callable[[dict], str] (see build_tool.py:49), but the
/context handler was stuffing the callable directly into tool_schemas,
giving the context analyzer a function reference instead of a string.
Also drop the dead `hasattr(spec, "to_dict")` branch — the Tool dataclass
has no such method.
Reuse the canonical tool_to_api_schema helper so /context and the real API
call site share one source of truth for the {name, description, input_schema}
shape.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2 tasks
singlaamitesh
pushed a commit
to singlaamitesh/clawcodex
that referenced
this pull request
Jul 7, 2026
…ext-schema fix(repl): resolve Tool.description to string in /context schema payload
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.
Follow-up to #162. Addresses the two non-blocking observations the reviewer flagged in the
/contexthandler.Summary
Tool.descriptionisCallable[[dict], str](seesrc/tool_system/build_tool.py:49), not a string. The/contexthandler was passing the callable straight intotool_schemas, so the downstream context analyzer received a function reference where it expected a string.hasattr(spec, "to_dict")branch was dead code —Toolis a dataclass with noto_dictmethod, so that branch was never taken.tool_to_api_schemahelper fromsrc/services/api/claude.py, which is the same converter the real API call site uses. Single source of truth for the{name, description, input_schema}shape.Test plan
test_handle_command_context_resolves_tool_descriptions_to_stringsasserts the populatedtool_schemas[0]["description"]is astr, not a callable./toolsregression test still passes.src/services/api/claude.pyonly depends on stdlib + sibling.errorsand.logging.🤖 Generated with Claude Code