Skip to content

fix(repl): resolve Tool.description to string in /context schema payload - #163

Merged
ericleepi314 merged 1 commit into
mainfrom
worktree-context-schema
May 17, 2026
Merged

fix(repl): resolve Tool.description to string in /context schema payload#163
ericleepi314 merged 1 commit into
mainfrom
worktree-context-schema

Conversation

@ericleepi314

Copy link
Copy Markdown
Collaborator

Follow-up to #162. Addresses the two non-blocking observations the reviewer flagged in the /context handler.

Summary

  • Tool.description is Callable[[dict], str] (see src/tool_system/build_tool.py:49), not a string. The /context handler was passing the callable straight into tool_schemas, so the downstream context analyzer received a function reference where it expected a string.
  • The hasattr(spec, "to_dict") branch was dead code — Tool is a dataclass with no to_dict method, so that branch was never taken.
  • Both are fixed by reusing the existing tool_to_api_schema helper from src/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

  • New regression test test_handle_command_context_resolves_tool_descriptions_to_strings asserts the populated tool_schemas[0]["description"] is a str, not a callable.
  • Existing /tools regression test still passes.
  • No circular import — src/services/api/claude.py only depends on stdlib + sibling .errors and .logging.

🤖 Generated with Claude Code

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>
@ericleepi314
ericleepi314 merged commit e1832a0 into main May 17, 2026
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant