Skip to content

Add Python / TypeScript code-style tool dispatchers - #184

Merged
senamakel merged 11 commits into
mainfrom
code-tool-dialect
Sep 22, 2026
Merged

senamakel merged 11 commits into
mainfrom
code-tool-dialect

Conversation

@senamakel

@senamakel senamakel commented Sep 22, 2026

Copy link
Copy Markdown
Member

Summary

Wires the new tinytools-agent code-call dialect into the agent loop:

  • ToolDispatcher::{Python, Typescript} are opt-in text dialects, never selected by Auto.
  • RunDialect::Code renders Python or TypeScript signatures, strips schemas from the wire, and shares the P-Format registry for batch and streaming recovery.
  • Text dialects always render an authoritative protocol block from the final post-middleware tools and effective tool choice. Arbitrary system-prompt headings cannot suppress current schemas or forced-choice instructions.
  • Updates the vendored TinyTools revision, documentation, and end-to-end coverage.

API or behavior changes

  • config::ToolDispatcher gains Python and Typescript with serde spellings python and typescript.
  • Source compatibility: because ToolDispatcher is a public exhaustive enum, downstream exhaustive matches must add arms for both variants. This intentional public API expansion must be accounted for in release versioning.
  • Existing Auto, Native, Xml, and Pformat selection behavior is unchanged.

Tests

  • cargo fmt --check
  • cargo clippy --workspace --all-targets -- -D warnings
  • cargo build --workspace --all-targets
  • cargo test -p tinyagents-harness --lib (1,230 passed)
  • cargo test -p tinyagents-integration-tests (all non-network tests passed)
  • cargo test --workspace --exclude tinyagents-harness --exclude tinyagents-integration-tests (all non-network tests passed)

New coverage includes Python and TypeScript dispatch, forced P-Format tool choices, structured-output recovery, and a regression proving that an untrusted protocol heading cannot suppress the current catalogue.

Bump the vendored tinytools submodule to commit 705677c, incorporating upstream fixes and improvements.

Auto-committed-on: macbook
Add opt-in `Python` and `Typescript` tool dispatcher variants that render tool schemas as code-style signatures in the system prompt, sharing P-Format's positional argument registry. Also skip appending the protocol block when the host has already rendered one, avoiding duplicate prompt content and token waste.

Auto-committed-on: macbook
Added tests covering Python and TypeScript code dialects, verifying that schemas are stripped from the wire and signatures are rendered into the system prompt. Also added a test ensuring a host-rendered protocol block is not duplicated when the dialect rewrite runs.

Auto-committed-on: macbook
Reformatted multi-line assert macros and the invoke_default call to comply with rustfmt line-width rules, wrapping expressions that exceeded the configured maximum line length. No behavior or test logic was changed.

Auto-committed-on: macbook
The tool dialect documentation now covers the newly added `CodeDialect` for Python and TypeScript call syntax, alongside the existing XML, P-Format, and native dialects. It also explains how the agent loop selects a dialect per run via `RunPolicy::tool_dialect`, including the automatic fallback to XML when native is unsupported, and clarifies that P-Format and code dialects are opt-in while the loop strips pre-composed schemas without duplicating the tool protocol block.

Auto-committed-on: macbook
@coderabbitai

coderabbitai Bot commented Sep 22, 2026

Copy link
Copy Markdown

Warning

Review limit reached

  • Run on-demand review

This review includes 11 billable files and costs up to $2.75.

Or wait 9 minutes for your next included review.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: 461d5dce-0a6c-45e5-910e-7b322bd36d67

📥 Commits

Reviewing files that changed from the base of the PR and between 1a2f3d0 and e38470d.

📒 Files selected for processing (11)
  • crates/tinyagents-harness/src/agent_loop/dialect.rs
  • crates/tinyagents-harness/src/agent_loop/dialect/test.rs
  • crates/tinyagents-harness/src/config/README.md
  • crates/tinyagents-harness/src/config/test.rs
  • crates/tinyagents-harness/src/config/types.rs
  • crates/tinyagents-harness/src/runtime/types.rs
  • crates/tinyagents-integration-tests/tests/e2e_tool_dialects.rs
  • docs/modules/harness/runtime.md
  • docs/modules/harness/tool-dialect.md
  • docs/modules/harness/tool.md
  • vendor/tinytools

Comment @coderabbitai help to get the list of available commands.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 22, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-22T02:29:53.281264Z e38470d New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@tinysweeper

tinysweeper Bot commented Sep 22, 2026

Copy link
Copy Markdown

Tiny Sweeper review

Tiny Sweeper reviewed this change across 6 lane(s) and found 5 active actionable finding(s). Detailed lane evidence and any incomplete work are listed below.

State: Ready for maintainer review
Priority: medium
Reviewed head: e38470d98b22
Updated: 1790044833 (Unix time)

Review snapshot

Change surface Files Review signal Count
Production 3 Active findings 1
Tests 3 Noted findings 0
Documentation 4 Resolved findings 14
Configuration 0 Pending checks/questions 0

Completeness: Complete
Test assessment: No supported feature-to-test mapping was available; this does not mean tests are absent or passed.

What changed

The review could not produce a supported behavioral summary; inspect the cited changed surface and lane details below.

Features

None identified with supported citations.

Tests

No supported feature-to-test mapping was produced. Test execution is not inferred.

Findings

  • medium · critique · Preserve compatibility for exhaustive ToolDispatcher matches — Adding `Python` and `Typescript` variants to the public `ToolDispatcher` enum makes existing downstream `match` expressions that exhaustively handle the previous variants fail to c (crates/tinyagents\-harness/src/config/README\.md:38)

Resolved this pass

  • Preserve required tool-choice instructions for host-rendered protocols
  • Show the actual P-Format argument syntax
  • Document Auto behavior for unknown model capabilities
  • Require an unambiguous marker for host-rendered protocols
  • Preserve required tool-choice instructions for host-rendered protocols
  • Preserve compatibility for exhaustive ToolDispatcher matches
  • Show the actual P-Format argument syntax
  • Document Auto behavior for unknown model capabilities
  • Require an unambiguous marker for host-rendered protocols
  • Preserve required tool-choice instructions for host-rendered protocols
  • Preserve compatibility for exhaustive ToolDispatcher matches
  • Show the actual P-Format argument syntax
  • Document Auto behavior for unknown model capabilities
  • Require an unambiguous marker for host-rendered protocols

Before merge

None.

How this fits together

flowchart LR
  n0["RunDialect<br/>changed"]:::changed
  n1["tool_dispatcher_round_trips_as_snake_case<br/>changed"]:::changed
  n2["ToolDispatcher<br/>changed"]:::changed
  n3["...d_pformat_dialect_parses_positional_calls<br/>changed"]:::changed
  n4["invoke_default"]:::impacted
  n5["...her_gates_on_the_post_middleware_tool_set"]:::impacted
  n6["set_default_model"]:::impacted
  n7["find"]:::impacted
  n8["run_loop_body"]:::impacted
  n1 -->|uses| n2
  n3 -->|calls| n4
  n3 -->|tests| n4
  n3 -->|calls| n6
  n3 -->|tests| n6
  n3 -->|calls| n7
  n3 -->|tests| n7
  n5 -->|uses| n2
  n5 -->|calls| n4
  n5 -->|tests| n4
  n5 -->|calls| n6
  n5 -->|tests| n6
  n8 -->|uses| n0
  classDef changed fill:#0d4429,stroke:#238636,color:#e6edf3
  classDef impacted fill:#161b22,stroke:#6e7681,color:#c9d1d9
  classDef flagged fill:#5a1e02,stroke:#d93f0b,color:#ffffff
  classDef blocking fill:#67060c,stroke:#f85149,color:#ffffff
Loading
Agent review details

critique

  • Conclusion: Success
  • Scope reviewed: all assigned evidence
  • Lane summary: Reviewed 3 files; 1 finding. _The code index is behind this pull request (indexed at `a4a290defdc5`), so retrieved context may be out of date._ _Memory was unavailable (model: cortex: v1/recall: timed out after 10s), so this review ran without it._
  • Evidence: crates/tinyagents\-harness/src/config/README\.md — Preserve compatibility for exhaustive ToolDispatcher matches

security

  • Conclusion: Neutral
  • Scope reviewed: all assigned evidence
  • Lane summary: No changed file has any attack surface. 3 files were not security-reviewed: crates/tinyagents-harness/src/config/README.md (prose or tabular data), docs/modules/harness/runtime.md (prose or tabular data), docs/modules/harness/tool.md (prose or tabular data).

tests

  • Conclusion: Success
  • Scope reviewed: all assigned evidence
  • Lane summary: (5 earlier finding(s) still open) _The code index is behind this pull request (indexed at `a4a290defdc5`), so retrieved context may be out of date._ _Memory was unavailable (model: cortex: v1/recall: timed out after 10s), so this review ran without it._

commits

  • Conclusion: Neutral
  • Scope reviewed: all assigned evidence
  • Lane summary: Nothing sensitive found in what this pull request commits.

description

  • Conclusion: Success
  • Scope reviewed: all assigned evidence
  • Lane summary: The documentation-only updates correctly enumerate the new `Python` and `Typescript` dialect variants in the `ToolDispatcher` enum and reference them as forced text dialects. No new issues are introduced in this commit; prior unresolved findings remain in the broader pull request but are not addressed here. (5 earlier finding(s) still open) _The code index is behind this pull request (indexed at `a4a290defdc5`), so retrieved context may be out of date._ _Memory was unavailable (model: cortex: v1/recall: timed out after 10s), so this review ran without it._

e2e

  • Conclusion: Neutral
  • Scope reviewed: all assigned evidence
  • Lane summary: No end-to-end harness in this repository: no e2e test files and no e2e workflow.
Evidence and run details
  • Models: ladder/vectors, gpt-5.6-luna, deepseek/deepseek-v4-flash, deepseek-v4-flash
  • Spend: $0.007225
  • Tokens: 116512 input · 11454 output · 25639 cached · 939 embedding
Head State Pass summary
68b0eb0abc49 changes requested 5 active finding(s), 0 resolved finding(s) (at 1790042247)
f4d1cf23b6c7 changes requested 5 active finding(s), 16 resolved finding(s) (at 1790044025)
e38470d98b22 ready for maintainer review 1 active finding(s), 14 resolved finding(s) (at 1790044833)

tinysweeper 0.1.0

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 68b0eb0abc

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread crates/tinyagents-harness/src/agent_loop/dialect.rs Outdated
Comment thread crates/tinyagents-harness/src/agent_loop/dialect.rs Outdated

@tinysweeper tinysweeper Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requesting changes: 1 lane(s) blocking, worst finding is high.

Fix or reply to the findings below and push. The next review clears this automatically once they are gone — you should not need to dismiss anything by hand.

             $0.0274 · 538,980 in / 16,809 out · 74,279 cached (14%) · ladder/vectors, gpt-5.6-luna, deepseek/deepseek-v4-flash · 849 embedded
critique:    $0.0146 · 278,045 in / 10,015 out · 30,283 cached (11%) · gpt-5.6-luna, deepseek/deepseek-v4-flash
security:    $0.0114 · 226,124 in / 4,813 out  · 21,086 cached (9%)  · gpt-5.6-luna
tests:       $0.0004 · 17,996 in  / 139 out    · 14,028 cached (78%) · deepseek/deepseek-v4-flash
description: $0.0003 · 8,954 in   / 83 out     · 4,989 cached (56%)  · deepseek/deepseek-v4-flash

Comment thread crates/tinyagents-harness/src/agent_loop/dialect.rs Outdated
Comment thread crates/tinyagents-harness/src/config/types.rs
Comment thread docs/modules/harness/tool-dialect.md
@tinysweeper tinysweeper Bot added the priority: p1 Next. Wrong behaviour a user will hit, or a security weakness behind a condition. label Sep 22, 2026
@senamakel senamakel self-assigned this Sep 22, 2026
senamakel and others added 4 commits September 22, 2026 05:08
Auto-committed-on: dragonfly
Co-authored-by: Medulla <medulla@tinyhumans.ai>
Update the vendored tinytools subproject to a newer commit, incorporating upstream changes.

Auto-committed-on: dragonfly
Co-authored-by: Medulla <medulla@tinyhumans.ai>
The previous logic skipped appending the protocol block when the system prompt contained a matching heading, but this could suppress the canonical block when the heading was merely mentioned in user-controlled text. The loop now always renders its authoritative block from the final post-middleware tool set, ensuring the correct dialect and catalogue are presented regardless of prompt content.

Auto-committed-on: dragonfly
Co-authored-by: Medulla <medulla@tinyhumans.ai>
The host prompt string was split across two lines, which is unnecessary and makes the test fixture harder to read. This change joins the string onto a single line without altering its content, keeping the test setup concise.

Auto-committed-on: dragonfly
Co-authored-by: Medulla <medulla@tinyhumans.ai>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f4d1cf23b6

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread crates/tinyagents-harness/src/config/types.rs
senamakel and others added 2 commits September 22, 2026 05:20
The ToolDispatcher enum now includes `Python` and `Typescript` as additional tool-call encoding strategies, alongside the existing `Auto`, `Native`, `Xml`, and `Pformat` variants. The documentation has been updated to reflect these new forced text dialects, which are used when parsing tool-call markup from assistant text in the runtime and when normalizing tool results in the harness.

Auto-committed-on: dragonfly
Co-authored-by: Medulla <medulla@tinyhumans.ai>
@senamakel
senamakel merged commit 492bac9 into main Sep 22, 2026
1 of 3 checks passed

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e38470d98b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

prompt_tools::with_tool_instructions(&messages, &tools, &request.tool_choice)
}
Self::PFormat(_) => {
Self::PFormat(_) | Self::Code(..) => {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Replay prior calls using the selected code syntax

When either new code dispatcher completes a tool call and enters another model iteration, coalesce_tool_results has already serialized the recovered structured call back into the generic JSON-in-tag form before this Self::Code arm appends Python or TypeScript instructions. The next request therefore demonstrates one call syntax in its history while requiring another in its system catalogue, undermining the selected dialect precisely during multi-tool loops; make transcript coalescing dialect-aware or replay these calls through CodeDialect. This also conflicts with the updated module documentation's definition of a dialect as including its history replay shape.

AGENTS.md reference: AGENTS.md:L78-L82

Useful? React with 👍 / 👎.

@tinysweeper tinysweeper Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The previously-blocking findings are resolved. Clearing the changes request.

             $0.0072 · 116,512 in / 11,454 out · 25,639 cached (22%) · ladder/vectors, gpt-5.6-luna, deepseek/deepseek-v4-flash, deepseek-v4-flash · 939 embedded
critique:    $0.0059 · 80,835 in  / 7,702 out  · 8,066 cached (10%)  · gpt-5.6-luna, deepseek/deepseek-v4-flash
tests:       $0.0005 · 18,299 in  / 191 out    · 12,360 cached (68%) · deepseek/deepseek-v4-flash
description: $0.0002 · 9,222 in   / 2,426 out  · 1,024 cached (11%)  · deepseek-v4-flash

`Native`, `Xml`, `Pformat`); modelled as an enum rather than a free-form
string so an unrecognised mode is a mapping error at the boundary, not a
silent fallthrough in the turn loop.
`Native`, `Xml`, `Pformat`, `Python`, `Typescript`); modelled as an enum

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

priority medium critique confident

Preserve compatibility for exhaustive ToolDispatcher matches

Adding Python and Typescript variants to the public ToolDispatcher enum makes existing downstream match expressions that exhaustively handle the previous variants fail to compile. Listing the variants here confirms that the breaking public surface remains present; either provide a compatibility strategy (such as a non-exhaustive enum and migration guidance) or explicitly handle this as a versioned breaking change before merging.

[RULE] public-api-compatibility ·

@tinysweeper tinysweeper Bot added priority: p2 Soon. Real but survivable — a rough edge, a gap, a thing that will bite later. and removed priority: p1 Next. Wrong behaviour a user will hit, or a security weakness behind a condition. labels Sep 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

priority: p2 Soon. Real but survivable — a rough edge, a gap, a thing that will bite later.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant