Skip to content

feat(core): introduce ToolCall.arguments_dict and ToolResult.from_value#211

Merged
seanbrar merged 1 commit into
mainfrom
feat/tool-dispatch-helpers
Jun 16, 2026
Merged

feat(core): introduce ToolCall.arguments_dict and ToolResult.from_value#211
seanbrar merged 1 commit into
mainfrom
feat/tool-dispatch-helpers

Conversation

@seanbrar

@seanbrar seanbrar commented Jun 16, 2026

Copy link
Copy Markdown
Owner

Summary

This PR adds ergonomics and safety improvements for handling tool arguments and results, and guarantees structured output serialization:

  • Adds ToolCall.arguments_dict() to strictly validate and retrieve parsed JSON-object arguments, failing fast with a ConfigurationError on malformed JSON or non-object arguments.
  • Adds ToolResult.from_value() constructor to automatically serialize non-string values to compact JSON and handle error payloads.
  • Updates Output.to_jsonable() to properly serialize Pydantic BaseModel structured outputs using value.model_dump(mode="json").
  • Modernizes docs/agent-loop.md to teach these recommended v2 patterns.

Related issue

None

Test plan

Run the local checking tool to execute all tests:

just check

Verified that 423 tests passed, including new unit tests covering:

  • JSON parsing and object-shape validation for arguments_dict().
  • Automatic serialization of generic JSON value types and strings for from_value().
  • Clean serialization of Pydantic models in to_jsonable().

Notes

None


  • PR title follows conventional commits
  • just check passes
  • Tests cover the meaningful cases, not just the happy path
  • Docs updated (if this changes public API or user-facing behavior)

@codecov

codecov Bot commented Jun 16, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 86.95652% with 3 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/pollux/interaction/tools.py 88.23% 2 Missing ⚠️
src/pollux/interaction/output.py 83.33% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@seanbrar seanbrar merged commit 91f7787 into main Jun 16, 2026
10 checks passed
@seanbrar seanbrar deleted the feat/tool-dispatch-helpers branch June 16, 2026 12:46
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