summaryrefslogtreecommitdiff
path: root/tests/fake-agy.lua
diff options
context:
space:
mode:
Diffstat (limited to 'tests/fake-agy.lua')
-rw-r--r--tests/fake-agy.lua24
1 files changed, 20 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