Skip to content

Forward response-budget query params on routed calls - #1533

Open
stonexer wants to merge 1 commit into
mainfrom
factory/557-routed-response-budget-query
Open

stonexer wants to merge 1 commit into
mainfrom
factory/557-routed-response-budget-query

Conversation

@stonexer

@stonexer stonexer commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

Problem

Routed parents such as treg.x.user.posts and treg.x.search.posts wrap the child's answer as {output, raw, _treg}. When AnyAPI serves the call, its large_result hint tells callers to re-run with jq, fields, max_items, or summary=true. Those controls exist on the child as queryParams and trim the response, not the charge. The generated routed catalog row listed only identity body fields, and the router built the child request from to_upstream identity mapping alone, so extra query values were dropped.

Public reproduction on main before this change:

  1. catalog_get treg.x.user.posts — body is username / user_id only; no queryParams.
  2. catalog_get anyapi.x.user.posts — lists fields, max_items, summary, jq.
  3. treg call treg.x.user.posts --data '{"username":"<public handle>"}' --query max_items=1 --query summary=true — HTTP 200, served by anyapi.x.user.posts, output.posts still had a full native page (20 items), raw duplicated the posts, and raw.hint still suggested those four controls.

Options

  1. Inherit and forward the child's response-budget query params (chosen). Generated routed rows copy fields, max_items, summary, and jq when at least one child declares them. After to_upstream, parent query keys among those names that the selected child declares are copied onto the child request; adapter-built query wins on a name clash. The child performs the trim; the parent still wraps the child's answer unaltered. Charge is unchanged.
  2. Trim on the parent after the child returns. Rejected: a routed endpoint never alters the child's answer, and billed rows must reach the caller.
  3. Tell callers to pin the AnyAPI child. Rejected: callers who only need a smaller envelope should not have to bypass routing.

Verification

  • On old code, the catalog gap and the live call above fail the hint: max_items=1 and summary=true do not change the envelope.
  • Unit tests: a generated row exposes exactly those four names (and no other child query names); forwarding happens only when the child declares them; adapter-built query is not overwritten; the two routed X tools inherit the names from the loaded catalog.

Generated routed rows now expose fields, max_items, summary, and jq when a
child declares them, and the router forwards those query values to a
serving child that accepts them so a large_result hint can be followed
without pinning that child.
@stonexer stonexer added the factory Fix PR produced by the feedback factory label Nov 8, 2026
@stonexer

stonexer commented Nov 8, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

@github-actions github-actions Bot added area:dashboard The web dashboard / landing / tutorials area:docs Documentation & design fragments labels Nov 8, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-08T20:39:37.903573Z d55717c Manual request
ℹ️ 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.

@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: d55717cb22

ℹ️ 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".

continue
try:
query, body = cand.adapter.to_upstream(plan.identity, cand.variant)
query = _with_parent_response_budget_query(parent, cand.endpoint, query)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Preserve routing evidence before forwarding shape-changing controls

When AnyAPI serves a routed call with jq=.output.data.tweets or summary=true, these controls can remove the structure the router still needs to classify the answer. anyapi.yaml documents that jq replaces output and summary returns only an outline, but the X posts adapters still read output.data.tweets / output.data.items. Consequently, child_outcome() classifies a successful, billed response as a miss, and the default waterfall calls more providers instead of returning the requested projection; if no later provider hits, it returns null output/raw despite having received results. Preserve the evidence needed for routing decisions, or explicitly handle projected responses, before enabling these controls. The current tests check forwarding but never classify a trimmed child response.

Useful? React with 👍 / 👎.

Comment thread tests/test_routing.py
Comment on lines +192 to +194
for eid in ("treg.x.user.posts", "treg.x.search.posts"):
qp = ((cat.by_id[eid].get("input") or {}).get("queryParams") or {})
assert set(qp) >= {"fields", "max_items", "summary", "jq"}, (eid, sorted(qp))

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Replace the endpoint-specific declaration test with generic coverage

This test hard-codes two catalog endpoint IDs and restates their query declarations, contrary to the explicit repository rule in AGENTS.md: “No per-endpoint tests” and tests restating declarations are to be deleted rather than extended. It couples the mechanism test suite to individual catalog rows without exercising routed execution. Remove this endpoint-specific assertion and cover response-budget inheritance and execution through generic behavioral tests instead.

AGENTS.md reference: AGENTS.md:L278-L280

Useful? React with 👍 / 👎.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:dashboard The web dashboard / landing / tutorials area:docs Documentation & design fragments factory Fix PR produced by the feedback factory

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant