Skip to content

(MOT-3890) feat(harness): session-cached contracts, batched functions::info, hydrated tool schemas - #435

Merged
ytallo merged 1 commit into
mainfrom
feat/harness-discovery-batch
Jul 7, 2026
Merged

(MOT-3890) feat(harness): session-cached contracts, batched functions::info, hydrated tool schemas#435
ytallo merged 1 commit into
mainfrom
feat/harness-discovery-batch

Conversation

@ytallo

@ytallo ytallo commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Summary

Live transcripts (208 sessions) showed 28% of all model function calls were engine::functions::list / engine::functions::info round-trips — driven by the prompt doctrine mandating a contract re-fetch before every call, single-id-only info, and a schema-less registry snapshot.

Pairs with the engine-side batch support in iii-hq/iii#1938 (engine::functions::info { function_ids: [...] }); the harness consumes it rather than shimming it.

  • Prompt doctrine (rebased over (MOT-3882) feat(providers): provider-owned system prompts, operator-overridable #430's provider-owned prompts: provider-anthropic/openai/xai prompts/identity.txt + the harness default.txt/cli.txt fallbacks; kimi.txt was removed upstream): a contract fetched once stays valid for the whole session; re-fetch only after an invalid_arguments-class failure or a registry-change notice. Teaches the engine's function_ids batch form. web/workflow injected guidance aligned. Because the batch is engine-native, the cli.txt teaching (iii trigger engine::functions::info --json '{"function_ids":[...]}') works for direct CLI callers too.
  • Discovery post-filter understands the batch envelope: entries the turn's policy denies are masked to the same { function_id, error: "not available" } stub the engine uses for unknown ids (masked, never dropped — denied stays indistinguishable from nonexistent); single-id results blank to null as before.
  • Snapshot hydration: discovery.rs fills each descriptor's parameters via function_ids batches of 32 — with a per-id fallback for engines predating batch support — so native/code-mode tools carry real schemas instead of {"type":"object"}.
  • Registry-change notice: the snapshot gains a fingerprint-gated generation; a mismatch against the session's watermark appends a one-line system-prompt notice and re-stamps. The watermark carries across turns via the turn record. A 5-minute safety reload covers dropped functions-available bindings.

Remaining engine follow-ups (schema-aware functions_hash, include_schemas on list): Refs MOT-3891.

Test plan

  • cargo test -p harness — all suites green (prompt pins rewritten; post-filter, discovery, and notice unit tests)
  • cargo fmt --check / cargo clippy --all-targets clean
  • Live smoke (batch-capable engine): direct CLI iii trigger engine::functions::info --json '{"function_ids":[...]}' returns 2 full contracts + a not_found marker in one call — no harness in the path
  • Live smoke — e2e doctrine: a harness::send turn made exactly ONE batched info call and reused contracts on later calls
  • Live smoke — hydration: boot seeds the registry with schemas via batch calls
  • Live smoke — notice: a registry change bumped the generation and the next session turn re-fetched the contract it relied on (validated pre-rebase; mechanism unchanged)

Fixes MOT-3890

@vercel

vercel Bot commented Jul 6, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
workers Ready Ready Preview, Comment Jul 7, 2026 2:58am
workers-tech-spec Ready Ready Preview, Comment Jul 7, 2026 2:58am

Request Review

@coderabbitai

coderabbitai Bot commented Jul 6, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@ytallo, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 47 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 04628dd0-6809-488a-93ac-9351648c3d74

📥 Commits

Reviewing files that changed from the base of the PR and between 9a1d8a8 and b79d24e.

📒 Files selected for processing (16)
  • harness/prompts/cli.txt
  • harness/prompts/default.txt
  • harness/src/clients/engine.rs
  • harness/src/deps.rs
  • harness/src/discovery.rs
  • harness/src/functions/send.rs
  • harness/src/prompt/tests.rs
  • harness/src/subagent.rs
  • harness/src/trigger.rs
  • harness/src/turn_loop.rs
  • harness/src/types/turn.rs
  • provider-anthropic/prompts/identity.txt
  • provider-openai/prompts/identity.txt
  • provider-xai/prompts/identity.txt
  • web/src/functions/inject_guidance.rs
  • workflow/src/functions/inject_guidance.rs
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/harness-discovery-batch

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@github-actions

github-actions Bot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

skill-check — worker

0 verified, 35 skipped (no docs/).

Layer Result
structure
vale
ai
render

Four for four. Nicely done.

…, hydrated tool schemas

Live transcripts showed 28% of all model function calls were
engine::functions::list / engine::functions::info round-trips, largely
driven by the prompt doctrine mandating a contract re-fetch before every
call.

- Prompt doctrine (provider-anthropic/openai/xai identity prompts + the
  harness default/cli fallbacks): a contract fetched once stays valid
  for the whole session; re-fetch only after an invalid_arguments-class
  failure or a registry-change notice. Teaches the engine's function_ids
  batch form of engine::functions::info. web/workflow injected guidance
  aligned.
- Discovery post-filter understands the engine's batch envelope:
  entries the turn's policy denies are masked to the same
  { function_id, error: "not available" } stub the engine uses for
  unknown ids (masked, never dropped — denied stays indistinguishable
  from nonexistent); single-id results blank to null as before.
- Registry snapshot hydration: discovery.rs fills each descriptor's
  parameters via function_ids batches of 32 (per-id fallback for
  engines predating batch support; failures keep the descriptor
  schema-less), so natively exposed tools carry real schemas instead
  of {"type":"object"}.
- Registry-change notice: the snapshot gains a fingerprint-gated
  generation; a mismatch against the session's watermark appends a
  one-line system-prompt notice and re-stamps. Watermark carries across
  turns via the turn record. A 5-minute safety reload covers dropped
  functions-available bindings.

Requires the engine's function_ids support for batch calls (falls back
gracefully on older engines for hydration; model-issued batch calls
surface the engine's error).
@ytallo
ytallo force-pushed the feat/harness-discovery-batch branch from c066407 to b79d24e Compare July 7, 2026 02:58
@ytallo
ytallo merged commit ffd8dd3 into main Jul 7, 2026
81 of 82 checks passed
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