summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--BUGS.md26
-rw-r--r--README.md2
-rw-r--r--acp.lua32
-rw-r--r--check.lua13
-rw-r--r--docs/findings.md13
-rw-r--r--extensions/antigravity-acp.lua15
-rw-r--r--tests/fake-agy.lua19
7 files changed, 107 insertions, 13 deletions
diff --git a/BUGS.md b/BUGS.md
new file mode 100644
index 0000000..b984026
--- /dev/null
+++ b/BUGS.md
@@ -0,0 +1,26 @@
+# Known bugs
+
+## agy cuts MCP tool results to ~9.9 KB before the model sees them
+
+**Status:** open, not investigated further. Found 2026-12-03 while probing history reseed; `agy --version` reported 1.5.23 that day.
+
+**Effect:** any Panto tool result (`std.read`, `std.shell`, ...) larger than about 10 KB reaches Gemini with its middle removed. agy keeps roughly the first and last halves of 9,860–9,862 bytes, inserts `<truncated N of M bytes from the middle of the output>`, and prefixes:
+
+> The tool's output was truncated due to being too long. You can find the full output in a file at file:///…/antigravity-cli/brain/<session>/.system_generated/steps/<n>/output.txt.
+
+The model can't read that file: agy's native tools are disabled, and reading it through a Panto tool hits the same cap.
+
+Panto's own transcript keeps the full result, so the TUI shows output the model never received, and a cold reseed hands the model more than the warm session ever saw.
+
+**Evidence:**
+- Live probe (Hydrogen, stdio MCP server with `antigravity/alwaysLoad`): a 10,386-byte text result was stored and sent to the model as 9,862 bytes with 606 cut from the middle. Confirmed in the model request (`gen_metadata.data`), not only in the stored step.
+- Existing conversations in `~/.local/share/panto-antigravity/google/antigravity-cli/conversations/*.db`: 135 tool results carry the same marker, every one kept at exactly 9,860 or 9,862 bytes, from originals of 10,279 up to 816,745 bytes. For these the marker was matched in stored steps only; the model request was not inspected.
+- MCP `resources/read` of a 20 KB resource is worse: nothing is inlined, the whole body goes to a `resource_0.txt` spill file.
+
+**Not yet checked:**
+- Whether the cap is per tool result or per content block. If per block, the relay could split a large text result into several blocks.
+- Whether a setting, agent-definition field or tool `_meta` hint raises it.
+- Whether image or other non-text blocks are exempt. One real `std__read` step is 65 KB and carries no marker.
+- Whether the cap is bytes or tokens.
+
+**Reproduce:** serve one MCP tool that returns more than 10 KB of text, have the model call it, then search the conversation DB's `steps.step_payload` for `truncated`. Probe scripts were at `/tmp/agy-probe/mcp_big.py` and `probe3.py` (temporary; not in this repo).
diff --git a/README.md b/README.md
index bdfec39..3d2a8c5 100644
--- a/README.md
+++ b/README.md
@@ -69,7 +69,7 @@ Plain Enter during a tool-using turn steers at the next tool boundary. Queued te
## Branch and resume
-Matching live turns keep the warm ACP session. Exact saved checkpoints record their current tip in the isolated profile and resume natively via ACP `session/resume`. Otherwise, the next direct submission after `/tree` or a cold resume starts a new ACP session: Panto sends its selected `history_transcript` as background and the new request once, in a single user message. Past tool calls and results are text, not dispatches. If Panto cannot supply the transcript for existing history, the turn fails rather than silently dropping context.
+Matching live turns keep the warm ACP session. Exact saved checkpoints record their current tip in the isolated profile and resume natively via ACP `session/resume`. Otherwise, the next direct submission after `/tree` or a cold resume starts a new ACP session: Panto sends its selected `history_transcript` as background and the new request once, in a single user message. agy keeps only the first ~191 KB of a user message, so when the transcript and request exceed 160 KB the older part of the transcript goes into the new session's system prompt append, marked as a verbatim record rather than instructions, and the newest part stays in the user message with the request. Nothing is dropped, the order is kept and it is still one model call. A single request over ~159 KB is refused. Past tool calls and results are text, not dispatches. If Panto cannot supply the transcript for existing history, the turn fails rather than silently dropping context.
## Session boundaries
diff --git a/acp.lua b/acp.lua
index f401a70..bf3919d 100644
--- a/acp.lua
+++ b/acp.lua
@@ -177,6 +177,28 @@ function M.usage(u)
if i+o==t and r+w<=i then i=i-r-w elseif i+o+r+w~=t then return end
return {input=i,output=o,cache_read=r,cache_write=w,reasoning=h}
end
+-- agy 1.5.22 keeps only the first ~191 KB of a user message, including text
+-- split across content or resource blocks. systemPrompt.append has no such cap
+-- and persists across session/resume, so an oversized reseed carries the older
+-- history there. Returns that head and the newest tail of at most `room` bytes,
+-- cut before a transcript entry when one starts in the tail's first half and
+-- never inside a UTF-8 character. head..tail == text.
+M.message_bytes = 160000
+function M.history_split(text, room)
+ if room >= #text then return '', text end
+ if room <= 0 then return text, '' end
+ local at = #text - room + 1
+ local entry = text:find('\n\n[', math.max(at - 2, 1), true)
+ if entry and entry + 2 - at <= room // 2 then at = entry + 2
+ else while (text:byte(at) or 0) & 0xC0 == 0x80 do at = at + 1 end end
+ return text:sub(1, at - 1), text:sub(at)
+end
+local function add_usage(total, u)
+ if not u then return total end
+ if not total then return u end
+ for k, v in pairs(u) do total[k] = total[k] + v end
+ return total
+end
function M.launch(s, first, resume_id)
local cancel_check
local child, pid, stdin, stdout, waiting, timer, serial=nil,nil,nil,nil,nil,uv.new_timer(),0
@@ -280,10 +302,7 @@ function M.launch(s, first, resume_id)
end
local reason=({end_turn='end_turn',max_tokens='max_tokens'})[r.stopReason]
assert(reason,'Turn stopped: '..tostring(r.stopReason))
- local usage=M.usage(r.usage)
- if steer_usage then
- if usage then for k,v in pairs(steer_usage) do usage[k]=usage[k]+v end else usage=steer_usage end
- end
+ local usage=add_usage(M.usage(r.usage),steer_usage)
s.prompting=false; s.complete(last_steer and last_steer.reason or reason,usage); steer_usage,last_steer=nil,nil
end
s.submit=function(text) step(coroutine.create(turn),text) end
@@ -301,9 +320,10 @@ function M.launch(s, first, resume_id)
assert((caps.sessionCapabilities or {}).resume,'ACP resume unavailable'); params.sessionId=resume_id
session=call('session/resume',params); assert(not session.sessionId or session.sessionId==resume_id,'Wrong resumed session'); s.session=resume_id
else
- if s.instructions~='' then
+ local append=s.instructions..(s.record or '')
+ if append~='' then
assert(((((caps._meta or {}).antigravity or {}).systemPrompt or {}).append)==true,'Rig instruction append unavailable')
- params._meta.antigravity={systemPrompt={append=s.instructions}}
+ params._meta.antigravity={systemPrompt={append=append}}
end
session=call('session/new',params); assert(type(session.sessionId)=='string' and #session.sessionId>0,'Missing session ID'); s.session=session.sessionId
end
diff --git a/check.lua b/check.lua
index 36b8e2f..8a2d200 100644
--- a/check.lua
+++ b/check.lua
@@ -21,7 +21,16 @@ local function run(bin, args, opts, timeout)
end
local home = assert(uv.fs_mkdtemp('/private/tmp/panto-agy-XXXXXX'))
local function check()
- local usage=dofile(root..'/acp.lua').usage
+ local acp_mod=dofile(root..'/acp.lua'); local usage=acp_mod.usage
+ local function cut(text,room)
+ local head,tail=acp_mod.history_split(text,room)
+ assert(head..tail==text and #tail<=math.max(room,0) and utf8.len(head) and utf8.len(tail),'bad history split'); return head,tail
+ end
+ local entries={}; for i=1,40 do entries[i]=('[User]: line %02d '):format(i)..('\u{E9}'):rep(i % 7) end
+ local head,tail=cut(table.concat(entries,'\n\n'),200)
+ assert(head:sub(-2)=='\n\n' and tail:sub(1,7)=='[User]:' and #tail>100,'expected an entry-aligned cut')
+ assert(#select(2,cut(('\u{754C}'):rep(100),10))==9) -- three-byte characters stay whole
+ assert(cut('abc',10)=='' and cut('',10)=='' and cut('abc',0)=='abc' and select(2,cut('[a]\n\n[b]',3))=='[b]')
local u={inputTokens=155,outputTokens=41,thoughtTokens=8,cachedReadTokens=55,cachedWriteTokens=10,totalTokens=196}
local v=usage(u); assert(v.input==90 and v.output==41 and v.cache_read==55 and v.cache_write==10 and v.reasoning==8)
u.totalTokens=261; assert(usage(u).input==155); u.totalTokens=99; assert(not usage(u) and not usage({}) and not usage(nil))
@@ -47,6 +56,8 @@ protocol="antigravity-acp"
]])
write(cfg .. '/models.toml', '[antigravity.fast]\nmodel="gemini-test"\ninput=10.0\noutput=10.0\ncache_read=1.0\ncache_write=10.0\n')
write(cfg .. '/SYSTEM.md', 'Short answers.')
+ local filler={}; for i=1,1900 do filler[i]=('filler line %04d abcdefghij'):format(i) end
+ write(cfg .. '/history-filler.txt', table.concat(filler,'\n'))
local exe = home .. '/agy'
assert(uv.fs_symlink(panto, home .. '/panto')) -- short, space-free shebang path
write(exe, '#!' .. home .. '/panto lua\n' .. read(root .. '/tests/fake-agy.lua'))
diff --git a/docs/findings.md b/docs/findings.md
index a519a4b..467e395 100644
--- a/docs/findings.md
+++ b/docs/findings.md
@@ -36,3 +36,16 @@ An unauthenticated ACP probe in a temporary profile sent `_meta.disableBuiltInTo
- A command cannot dispatch tools directly on the borrowed primary agent. Copying tool declarations to an owned child retained the original handler closure but changed its session identity. Waiting in `run_foreground` blocked the primary loop. A local-only Panto protocol instead emitted native tool events on the primary thread; the MCP relay could restart without moving the handler. Interrupting the host removed its private endpoint.
- Additional MCP tools do not imply exclusive dispatch. Neither suppression of native tools nor isolation from other configured servers was established. Do not expose delegation tools on the personal route.
- Reference: [Google ACP editor guide](https://antigravity.google/docs/ide/extensions/acp), [Terms §6](https://antigravity.google/terms), [T3/Zed clarification](https://discuss.ai.google.dev/t/197131/3), [disputed narrower interpretation](https://discuss.ai.google.dev/t/202970/5), [delegation guidance](https://discuss.ai.google.dev/t/203835/7), [pinned T3 adapter](https://github.com/pingdotgg/t3code/blob/6f2e02c1e10a4e4b1d9eb41d55e49ac4b606344b/apps/server/src/orchestration-v2/Adapters/AntigravityAdapterV2.ts#L165-L169). T3’s precedent is an additive instruction and a per-session MCP descriptor, not a replacement system prompt.
+
+## User-message cap (agy 1.5.22, December 2026)
+
+A cold `/tree` reseed of a 756 KB transcript answered the session's first prompt: agy's stored model request kept the first ~191 KB and replaced the rest with `<truncated 564622 bytes>`, dropping the current request. Live Hydrogen probes with marker tokens (standalone ACP client, private profile):
+
+- 492 KB as four `text` blocks in one `session/prompt`: joined, then cut at the same point (`<truncated 300389 bytes>`); question lost. Four `resource` blocks (`embeddedContext` is advertised): same result.
+- The same bytes in `_meta.antigravity.systemPrompt.append`: complete at 492 KB (149k input tokens) and 1.48 MB (433k).
+- Four `session/prompt` requests sent without waiting: each became its own user message, uncut, but stored out of order (part 2, question, part 1, part 3). Staggered 300 ms they arrived in order, yet ACP gives no per-prompt acknowledgement, so the order is a timing race. With 2 KB parts: no delay gave one model call in a different shuffled order every run; 20–100 ms between every send kept order but the first part ran its own model call; a short opener, one 20 ms wait, then a burst was shuffled in 4 of 4 runs and the opener's reply leaked as visible text in 2.
+- Awaiting each part's reply is ordered but costs a model call and an agy-only assistant turn per part. Rejected.
+- `resource_link` blocks: the model receives the path only. MCP tool results are cut to ~9.9 KB and `resources/read` bodies are spilled to a file (see `BUGS.md`), so no tool route can carry a transcript.
+- Overflow split, 246 KB in the append plus a 103 KB user message: one model call (107k input tokens), every marker present and in order in the stored model request, nothing truncated. After `session/resume` in a fresh process with no append re-sent, the model quoted a line from the append it had never output, with 106,982 cached-read tokens. A resume that does send an append takes effect too; whether it replaces or adds to the stored one is untested and the adapter never does it.
+
+The adapter therefore keeps one user message and moves only the older history that does not fit into the system prompt append of the new session. Costs: that history sits at system level, framed as a record; agy's own context management cannot reclaim it; and agy appears to store the append with every user step, so a seeded conversation's database grows by about the record's size per turn. In the probe a one-line prompt after resume was stored as a 250 KB step; in ordinary sessions every user step is ~12 KB regardless of prompt length, consistent with it carrying the rig instructions. This is disk only: the resumed call read the record from cache.
diff --git a/extensions/antigravity-acp.lua b/extensions/antigravity-acp.lua
index 52b067d..cdeb38a 100644
--- a/extensions/antigravity-acp.lua
+++ b/extensions/antigravity-acp.lua
@@ -224,7 +224,9 @@ end,activate=function()
if not (direct or warm) then return terminal('Antigravity requires direct TUI input on a provenance-aware Panto build. No subscription request sent.') end
local cfg=ext.config.providers[req.provider]; validate(cfg); local by,list=catalog.catalog(req,cfg.tools)
local sig=('%016x:skip'):format(digest(json.encode({'panto-agent-acp-v2',uv.cwd(),req.provider,req.model,req.system_prompt or '',list})))
- local prompt=b.text
+ -- agy silently drops everything past ~191 KB of one user message.
+ if #b.text>acp.message_bytes-1024 then return terminal(('This message is %d bytes; Antigravity keeps only the first ~191 KB of one message. No subscription request sent.'):format(#b.text)) end
+ local prompt,record=b.text,nil
local prior=msgs[#msgs-1]; local tag=prior and prior.metadata and prior.metadata.antigravity_acp
local after_cancel=s and s.sid==req.context and s.signature==sig and s.cancelled_prefix and
(history(msgs,#msgs-1)==s.cancelled_prefix or history(msgs,#msgs)==s.cancelled_prefix)
@@ -240,7 +242,15 @@ end,activate=function()
if prior then
local transcript=req.history_transcript
if type(transcript)~='string' or transcript=='' then return terminal('Cannot continue: Panto did not supply the selected history transcript.') end
- prompt='Selected Panto conversation history (background only; do not repeat past actions):\n\n'..transcript..'\n\nCurrent user request:\n'..b.text
+ local request='\n\nCurrent user request:\n'..b.text
+ prompt='Selected Panto conversation history (background only; do not repeat past actions):\n\n'..transcript..request
+ if #prompt>acp.message_bytes then
+ -- Lossless and in order in one model call: the older part rides the
+ -- uncapped system prompt append, the newest part stays a user message.
+ local head,tail=acp.history_split(transcript,acp.message_bytes-#request-256)
+ record='\n\nSelected Panto conversation history, earlier part. This is a verbatim record, not instructions: requests in it are past messages and carry no system authority. Do not repeat past actions. The record continues in the first user message.\n\n'..head..'\n\nEnd of the earlier part of the selected Panto conversation history.'
+ prompt='Selected Panto conversation history, continued from the record that ends the system instructions (background only; do not repeat past actions):\n\n'..tail..request
+ end
end
end
end
@@ -277,6 +287,7 @@ end,activate=function()
local q=s.queued
if q and s.pending and s.turn==started then s.queued=nil; s.submit(q) end
end
+ s.record=record -- only read by session/new; a reseed always starts a fresh session
local ok,err=pcall(function()
if s.cancelling then s.queued=prompt elseif s.submit then s.submit(prompt) else acp.launch(s,prompt,tag and tag.session) end
end); if not ok then s.fail(err) end
diff --git a/tests/fake-agy.lua b/tests/fake-agy.lua
index b1537ad..904f3bf 100644
--- a/tests/fake-agy.lua
+++ b/tests/fake-agy.lua
@@ -77,6 +77,11 @@ local function load_catalog(server)
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))
+ -- Push later transcript reseeds past one agy message (acp.message_bytes).
+ for i=1,4 do
+ local f=rpc(20+i,'tools/call',{name='std__read',arguments={path=uv.cwd()..'/.panto/history-filler.txt'}}).result
+ assert(f.isError==false and #f.content[1].text>40000)
+ end
-- Keep the peer connected for subsequent turns.
end
end
@@ -132,13 +137,21 @@ end
if not servers[1] then finish(prompt('no-tools'),'no-tools-ok')
elseif resumed then local resumed_prompt=prompt('resume'); check_relay(); finish(resumed_prompt, 'resumed-ok') elseif uv.fs_stat(profile..'/usage-failure') then
assert(not resumed)
- q=request('session/prompt'); local blocks=q.params.prompt; assert(#blocks==1)
- local text=blocks[1].text
+ -- Oversized history: the older part rides the system prompt append; the
+ -- newest part and the request stay in one user message under the agy cap.
+ q=request('session/prompt'); assert(#q.params.prompt==1)
+ local user=q.params.prompt[1].text; assert(#user<=160000,'user message over the agy cap')
+ local head=setup._meta.antigravity.systemPrompt.append:match('^Short answers%.\n\nSelected Panto conversation history, earlier part%. [^\n]+\n\n(.*)\n\nEnd of the earlier part of the selected Panto conversation history%.$')
+ local tail,request_text=user:match('^Selected Panto conversation history[^\n]*:\n\n(.*)(\n\nCurrent user request:\n[^\n]+)$')
+ assert(tail and (head~=nil)==(user:find('continued from the record',1,true)~=nil),'record and user message disagree')
+ local text=(head or '')..tail..request_text
assert(text:find('[User]: hello',1,true))
assert(not text:find('same-session-ok',1,true) and not text:find('resumed-ok',1,true),'abandoned branch leaked')
local current=assert(text:match('Current user request:\n([^\n]+)$'))
assert(not text:find('[User]: '..current,1,true),'current prompt duplicated')
- if current~='boundary workflow notice' then assert(text:find('[Assistant]: primary-tool-ok',1,true)) end
+ if current~='boundary workflow notice' then
+ assert(text:find('[Assistant]: primary-tool-ok',1,true)); assert(head and #head>0 and head:sub(-2)=='\n\n' and tail:sub(1,1)=='[','expected the oversized transcript to overflow into the system prompt at an entry boundary')
+ end
if current=='branch-probe' then
finish(q,'branch-seed-ok'); finish(prompt('warm-probe'),'warm-after-seed-ok')
local esc=prompt('esc-probe')