Repository navigation
Integrations: MCP big lists and input-required rounds, LangChain parallel asks, tracekit last, gateway listing errors - #753
Merged
Conversation
…llel asks, tracekit last, gateway listing errors - MCP client (#685): a list page over half a signer frame is recorded as its digest (result_field, as the gateway does), so list_tools no longer fails with quota_exceeded; mcp's own re-list inside call_tool (validate_tool_result) is no longer recorded as input the model read. - MCP input-required rounds (#718): a pending round is keyed by the asyncio task driving the call, so a server that reuses request_state can't move one call's result under another's decision; a call the task leaves between rounds completes with the input request it returned. - LangChain (#687): a call whose approval is already answered doesn't pause again, so in a tracekit_tool_node with two asks the approved call runs on resume (16 of 16 on invoke and ainvoke); the call still waiting is refused. - tracekit last: OpenCode, Kilo, goose and Antigravity runs finish at the signer's idle timeout, not when the session ends. - MCP gateway: the repeated-cursor error says what happened; a listing past its shared 600 s budget names the upstream; docs/mcp-gateway.md documents the budget.
…, so no call runs in a pass that then pauses ToolNode runs a message's calls in one node, which LangGraph runs again from its start on each resume. A call that ran in a pass that then paused ran again or read as refused: an allowed sibling of one ask ran twice, and with three or more asks a call that ran was refused on the next pass while an approved one never ran. A gated ToolNode (tracekit_tool_node, or one instrument() wired) now decides a pass's calls together first (TracekitMiddleware._pass) and pauses once, before any runs, while an approval is unanswered; the payload's `approvals` lists every waiting one. On resume each allowed or approved call runs once and each rejected or unanswered one is refused. The hook is ToolNode's class-level node function and acts only while the node's wrapper is the gate's, so tracekit why's replay copy (its own wrapper) runs no real tool. Replaces the lean note.
…utor's call stays the executor's LangGraph pairs resume values with a node's interrupt() calls by order. Once an approval was answered the gate stopped pausing, so a tool that asked the person itself got the approval's resume value and ran without asking. The gate now pauses for an ask in every pass of its node, answered or not (a ToolNode pass once, when any call asks), so a tool's interrupt() always comes after it. A call whose tool paused the run after its consume goes on, consumed once, on resume (main refused it as TK-APPROVAL-CONSUMED); in a held ToolNode pass, calls that already ended are given back, not decided, asked, run or recorded again. Both are kept in memory; docs and limits say what a resume in another process does. _pass leaves a tool executor's calls to the executor. The MCP gateway's listing timeout also catches concurrent.futures.TimeoutError, a separate class before Python 3.11.
…to its own PR The multi-call ToolNode changes (#687) keep exposing new cases (RetryPolicy re-raising a kept exception, async sibling cancellation), so this PR keeps main's langchain.py, autowire.py, their tests and doc. The held-pass design moves to a draft PR for after 1.7.0. docs/limits.md says what main does with several asks in one ToolNode. The fork-replay leak found earlier came from this branch's own hook and isn't on main.
… call denied and unrun
…ngGraph row - MCP: a multi-round call its task leaves (the elicitation callback fails, the rounds run out, the caller moves on) is never completed later; it was completed "ok" with its input request when the task made another call, though its caller had got an exception. It ends as the signer's decided_not_completed gap at run close, as the docs say. - MCP gateway: only the listing's own time running out (Upstreams._run's wait, now UpstreamTimeout) is reported as the listing's budget; a TimeoutError the upstream call or the reconnect raises keeps the upstream error and its advice. - Tests: a round's input requests over half a frame are recorded as a digest. - Limits: the LangGraph parallel-asks row says what happens under invoke and ainvoke alike, with what-to-dos checked against the code; a row for MCP rounds sent from different tasks. Signed-off-by: LoopGlitch26 <53336715+LoopGlitch26@users.noreply.github.com>
…er; a reconnect with no session names the upstream; MCP docs say which decisions wait and which calls end a waiting one Signed-off-by: LoopGlitch26 <53336715+LoopGlitch26@users.noreply.github.com>
…thing was sent; a call that ends as its wait is cancelled gives its answer; docs on the reconnect's time and which decisions wait Signed-off-by: LoopGlitch26 <53336715+LoopGlitch26@users.noreply.github.com>
This was referenced Nov 12, 2026
Merged
Closed
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.
Fixes these integration findings from the 1.7.0 pre-release review:
tracekit lastmessage for agents without a session-end hook;#687 moves to draft #756, design first.
What and why
#685, MCP client: lists too big for a signer frame (
tracekit/integrations/mcp.py)list_*sent the whole page inobserve. Atools/listover the signer's 1 MiB frame (230 tools with 40-field schemas is enough) madelist_toolsraisequota_exceededwhatever the fail mode. The page now goes throughresult_field(True, …), as the MCP gateway does: a page over half a frame is recorded as its digest. The input-requiredobservedoes the same.ClientSession.call_toollists the tools again (validate_tool_result) to check a result against the output schema. Underinstrument()that list was recorded as untrusted input the model read, and a big one made the call fail after the tool ran. That list never reaches the model, so it is no longer recorded: the session's send runs under the existingDECIDED_UPSTREAMflag, which instrument()'s patchedlist_toolsalready passes through. I chose not recording it over recording it as "internal": it is the smaller change, and there is no record kind for internal input.#718, MCP input-required rounds (
tracekit/integrations/mcp.py)request_state). A server that reuses a state let call B's result be signed under abandoned call A's id and decision, and B was completed "ok" at round 1.Client.call_tooldrives every round from one task, and concurrent calls run in separate tasks. A round continues only the call its own task left waiting, with the same tool, arguments and the state that call got.decided_not_completedgap. The weak keys also retire the oldlean:note about pending entries living for the session's life.#687 (several asks in one LangChain ToolNode) is not in this PR. The patches here kept exposing new cases: a tool's own
interrupt(),RetryPolicy, async sibling cancellation, and a resume in another process. So this PR keeps main'slangchain.pyandautowire.py.docs/limits.mdnow says exactly what main does: each resume answers one pause and the run pauses again; underainvokea pause may show an already-approved call; a call that ran on an earlier resume is gated again and deniedTK-APPROVAL-UNBOUND; an allowed call beside the asks runs again on each resume. The redesign is draft #756 (design first, after 1.7.0). An earlier version of this branch found atracekit whyfork-replay leak, where a real tool ran during replay. It came from that version's own hook and isn't on main, so nothing ships for it.tracekit last(tracekit/cli.py): it said an open run "finishes when the session ends" for OpenCode, Kilo, goose and Antigravity, which install no session-end hook. For those it now says:still open: Tracekit's <agent> hooks get no session end, so it finishes after the signer's idle timeout. For Cline (#732, merged meanwhile), a run is one task, so it saysit finishes when the Cline task completes, or after the signer's idle timeout (a cancelled task sends no hook).MCP gateway (
tracekit/mcp_gateway.py,docs/mcp-gateway.md)tools/list page 2 returned a cursor an earlier page had returned, so the listing would never end; fix the upstream's cursor). It used to name the 100-page cap, which the listing never reached.upstream error: TimeoutError: ; the gateway connects to an upstream that went away again on the next call. It now saysupstream 'up': tools/list timed out (one listing has 600 s for every upstream and page), catchingconcurrent.futures.TimeoutErrortoo: before Python 3.11 that is a separate class.Evidence
Regression tests. Each one fails on the old code. I checked them in a scratch copy of
origin/main(c5a3923) with only the new tests added: all 8 failed. The digest fix alone, without the re-list flag, still fails the call_tool test.tests/test_contract_mcp.py:BigLists(real signer: a 300-tool, about 1.4 MB list is recorded as its digest;call_toolwith no list first records noinput.observed) andInputRequiredRounds(a lowlevel server that reuses its state: two concurrent calls give exactly 2 decisions, each completed under its own; a call left after round 1 completes before the next call is decided).tests/test_instrument.py:tracekit lastagainst open opencode, kilo, goose, antigravity and cline runs on a real dev signer.tests/test_mcp_gateway.py: the repeated-cursor and budget messages, and the budget error with aconcurrent.futures.TimeoutErrorthat isn't the built-in one (as on Python 3.10).The reviewer's probes, re-run on this branch (before the fix:
list_tools raised: RPCError quota_exceeded: the observe request is 1842028 bytes…; 3 decisions for 2 concurrent calls):Gates in the worktree on the final head, with origin/main merged in (
make test-ts lint build test): TStests 162, pass 152, fail 0; pyflakes clean;Successfully built tracekit_ai-1.6.0.tar.gz and tracekit_ai-1.6.0-py3-none-any.whl; pytest4978 passed, 394 skipped, 10 xfailed, 0 failed.The branch merges origin/main (with #732) instead of rebasing onto it. The branch was already pushed, and rebasing would have needed a force-push.