diff options
| author | t <t@tjp.lol> | 2026-12-01 17:42:15 -0700 |
|---|---|---|
| committer | t <t@tjp.lol> | 2026-12-04 13:53:47 -0700 |
| commit | b4c1ad53077556e5401569a41a739f58a5ab2c86 (patch) | |
| tree | 0b121e7c16c7c7c385d68a2d6e4b24866b13f86f /tests | |
| parent | 8c1c5786ebfe8dda40a70571f332e876b184ad4d (diff) | |
Drain slow MCP tool results after ACP cancellation or disconnect
agy can time out and cancel or disconnect an MCP request while Panto is still
running the local tool. Failing immediately broke the turn or risked replying
to a cancelled request.
Request a 30-minute MCP timeout (timeoutSeconds=1800) for the pantograph relay
and track Panto's active tool handoff (s.issued) independently of the
cancellable MCP call. Keep the ACP idle timer alive while s.issued is pending,
let notifications/cancelled and MCP disconnects clear s.call without aborting
the turn, hold completion in s.settle until the local tool result and any
queued steering drain, and record failed_handoff so a failed handoff surfaces
on continuation. Document slow-tool handling in README.md and add a late-tool
acceptance fixture in check.lua, tests/fake-agy.lua, and tests/tui.exp.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/fake-agy.lua | 24 | ||||
| -rw-r--r-- | tests/tui.exp | 1 |
2 files changed, 21 insertions, 4 deletions
diff --git a/tests/fake-agy.lua b/tests/fake-agy.lua index ae671c3..4f76d8d 100644 --- a/tests/fake-agy.lua +++ b/tests/fake-agy.lua @@ -43,9 +43,12 @@ local function load_catalog(server) local input, output = assert(uv.pipe()), assert(uv.pipe()) local proc = assert(uv.spawn(server.command, {args=server.args, stdio={input.read, output.write, 2}}, function() end)) uv.fs_close(input.read); uv.fs_close(output.write) - local function rpc(id, method, params) + local function write(id, method, params) local line = json.encode({jsonrpc='2.0', id=id, method=method, params=params or {}}) .. '\n' assert(uv.fs_write(input.write, line, -1) == #line) + end + local function rpc(id, method, params) + write(id,method,params) local buf = '' repeat local chunk = assert(uv.fs_read(output.read, 4096, -1)); assert(chunk ~= '', 'relay closed'); buf = buf .. chunk @@ -56,14 +59,25 @@ local function load_catalog(server) local tools = rpc(2, 'tools/list').result.tools local schemas={}; for _,t in ipairs(tools) do assert(t._meta['antigravity/alwaysLoad']==true); schemas[t.name]=t.inputSchema end assert(schemas.std__read and schemas.std__edit and schemas.fixture__echo.properties.rows.items.required[1]=='value') - return function() + return function(late_prompt) + if late_prompt then + write(7,'tools/call',{name='fixture__echo',arguments={rows={{value=43}}}}) + while not uv.fs_stat(profile..'/tool-running') do uv.sleep(10) end + write(nil,'notifications/cancelled',{requestId=7}) + assert(rpc(8,'ping').result) -- cancellation consumed while Panto still owns call 7 + finish(late_prompt,'timeout-handled-ok') + send({id='barrier',method='fixture/barrier'}) + assert(read().id=='barrier') -- ACP finished before the local tool returned + local f=assert(io.open(profile..'/return-result','w')); f:close() + return function() assert(rpc(9,'ping').result) end -- no late reply to 7 + end assert(rpc(3, 'tools/call', {name='not_exported', arguments={}}).error.code == -32602) assert(rpc(5, 'tools/call', {name='fixture__echo', arguments={rows={{value='bad'}}}}).error.code == -32602) local echo=rpc(6, 'tools/call', {name='fixture__echo', arguments={rows={{value=42}}}}).result assert(echo.isError==false and echo.content[1].text=='42') local r = rpc(4, 'tools/call', {name='std__read', arguments={path=uv.cwd() .. '/.panto/SYSTEM.md'}}).result assert(r.isError == false and r.content[1].text:find('Short answers', 1, true)) - proc:kill('sigkill'); uv.fs_close(input.write); uv.fs_close(output.read); uv.run(); proc:close() + -- Keep the peer connected for subsequent turns. end end @@ -85,6 +99,7 @@ if uv.fs_stat(profile..'/no-tools') then assert(#servers==0) else assert(#server assert(#setup.mcpServers==#servers) local server=setup.mcpServers[1] if server then + assert(server.timeoutSeconds==1800 and servers[1].timeoutSeconds==1800, 'expected 30-minute timeout in ACP setup and generated agent') assert(server.name==servers[1].name and server.command==servers[1].command and json.encode(server.args)==json.encode(servers[1].args) and json.encode(server.env)=='[]') end local check_relay=server and not uv.fs_stat(profile..'/skip-list') and load_catalog(server) @@ -144,6 +159,7 @@ else finish(q, 'primary-tool-ok'); reply(steer,{stopReason='end_turn',usage={inputTokens=1000,outputTokens=6,totalTokens=1006}}) -- out of request order also works set_level('high') finish(prompt('again'), 'same-session-ok') - finish(prompt('[subagents] Workflow fixture completed. Output below: marker'), 'workflow-notice-ok') + local verify=check_relay(prompt('late-tool')) + q=prompt('[subagents] Workflow fixture completed. Output below: marker'); verify(); finish(q, 'workflow-notice-ok') end for _ in io.lines() do end -- keep the session alive until Panto closes stdin diff --git a/tests/tui.exp b/tests/tui.exp index b8cdf4d..77ef267 100644 --- a/tests/tui.exp +++ b/tests/tui.exp @@ -20,6 +20,7 @@ foreach {prompt answer} {hello primary-tool-ok again same-session-ok} { send -- "/reasoning high"; see {/reasoning high}; send -- "\r"; see {reasoning -> high} } else {see $answer} } +send -- "late-tool"; see {late-tool}; send -- "\r"; see {timeout-handled-ok} send -- "/fixture-notice "; see {/fixture-notice }; send -- "\r"; see {workflow-notice-ok} send -- "\003"; expect eof; wait set flag [open "$env(HOME)/.local/share/panto-antigravity/google/usage-failure" w]; close $flag |
