feat(overflow): disclose the relay on MCP; scope an aggregator's own 4xx to the request - #414
Merged
Merged
Conversation
A free endpoint served through the overflow relay bills the relay's price (apollo.people.search: 8,810 calls at $0.002 on 2026-09-08) and nothing on the MCP surface said so. The call result now carries served_via and a hint, and catalog_get shows overflow_price_usd up front.
…f striking the aggregator One Orthogonal validation 400 read as malformed took overflow:orthogonal offline for every org for 15 minutes on 2026-09-08. A bare 4xx with no vendor data is the aggregator's per-request refusal: no vendor call, no charge, no strike; malformed is reserved for non-JSON bodies, 5xx and transport errors. Also corrects the stale $20/day aggregator budget in money.md.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Split out of #400 because it changes capacity policy for every overflowed call, not one provider's billing rule. Two commits so the policy half can be reviewed and reverted on its own.
1. Disclose the relay on the MCP surface (low risk)
When treg's own account for a provider is marked out, a platform-eligible endpoint may be served through the overflow relay at the aggregator's real price with 0% markup. That is the documented contract (AGENTS.md non-negotiable 4, money.md "Overflow money", llms.txt, skill.md,
treg org overflow off), and/call/says so inX-Treg-Served-Via. The MCPcalltool dropped that header andcatalog_getshowed only the direct price, so an agent on apollo.people.search (catalog: free) sawcost_usd 0.002with no explanation. Ledger for 2026-09-08: 100,113 Apollo searches, 24,960 through the relay, 8,810 billed $0.002. Six feedback reports from one org.callresult carriesserved_viaand a one-line hint when it names an overflow aggregator (shared_call_impl, so both/mcp/and/mcp/v2/).catalog_getandGET /catalog/{id}exposeoverflow_price_usd,overflow_price_unit,overflow_viafor endpoints the deployment can relay, and the run hint says a "free" endpoint may bill that price.2. Scope an aggregator's own 4xx to the request (policy change)
One Orthogonal validation 400 with no vendor data was classified
malformed, which is aggregator-side and struckoverflow:orthogonalfor 15 minutes for every org; with the direct tier skipped, every call in that window failed asprovider_capacity_unavailable. A bare 4xx from the aggregator (400/422 validation, 404 for a slug it no longer lists) is nowcontract: request-scoped, no vendor call, nothing charged, no strike, and on the skip-direct ladder the caller gets treg's typed 503 naming the refusal rather than the aggregator envelope.malformedis reserved for non-JSON bodies, 5xx and transport errors. 402 and 401/403 keep their aggregator-side meaning.Trade-off to weigh: repeated bad requests now reach Orthogonal every time instead of being short-circuited for 15 minutes. Also corrects money.md's stale $20/day aggregator budget (render.yaml sets $500).
Not changed: when a free endpoint is diverted to overflow. Today a zero-cost endpoint is skipped on the same exhausted signal as a paid one, including a credit-balance reading from the capacity sweep; whether a $0 direct call should ever be diverted to a paid relay is a product decision left open.
Verification
uv run --with pytest-xdist pytest -n auto: 3203 passed, 5 skipped.test_alembic_head_has_no_model_driftpasses against a privateTREG_TEST_DB_URL; the shared sqlite files under$TMPDIR/treg-testsare contaminated on this machine by other checkouts' runs.lint-imports: 14 contracts kept.drift.sh origin/main..HEAD: every changed source maps to a fragment updated in these commits (the mixed docs, money.md and proxy-model.md, sit in the second commit).