Skip to content

feat(agy): offload large prompts to temp file for agy CLI - #400

Open
mvance wants to merge 9 commits into
steipete:mainfrom
mvance:feat/agy-large-prompt-offload-v2
Open

feat(agy): offload large prompts to temp file for agy CLI#400
mvance wants to merge 9 commits into
steipete:mainfrom
mvance:feat/agy-large-prompt-offload-v2

Conversation

@mvance

@mvance mvance commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Summary

Follow-up replacement for #389. Offloads prompts exceeding platform argv limits (or command length limits on Windows) to a secure temporary file (document.txt) with 0o600 permissions in the Antigravity (agy) CLI runner.

Resolution of Precursor (#389) Concerns

  1. Preventing Prompt Meta-Summarization: In feat(agy): offload large prompts to temp file for agy CLI #389, the entire formatted prompt (instructions + XML template + payload) was written to prompt.txt, causing agy to meta-summarize the prompt template itself rather than executing the summarization task on the document. In this PR, only the raw document <content> payload is offloaded to document.txt.
  2. Instruction Retention in --print: System instructions (<instructions>, <context>) and post-content formatting rules remain directly in the --print command argument (Summarize the content in file://.../document.txt), ensuring agy receives system instructions in argv while reading the heavy payload from the file.
  3. UTF-16 & Tag Safety: Uses a case-insensitive index helper (lastIndexOfCaseInsensitive) on the original string rather than a lowercased copy, preventing UTF-16 length-changing characters (e.g. İ U+0130) or literal <content> text in instructions from shifting index boundaries or corrupting payload extraction.
  4. Non-Interactive Guidance: Appends explicit text instructions (Do not create or edit files. Do not include local file links or work-log narration.) when allowTools is false.
  5. Pre-flight & Post-flight Size Enforcement: Includes timeout flags and guidance text in pre-flight limit calculations, ensuring offloading triggers whenever needed and total command length limits are strictly enforced.
  6. Guaranteed Cleanup: Temporary prompt directories are deleted in finally blocks on success, failure, or timeout.

Empirical Behavior Proof

Executed summarize --cli agy --plain against a 159 KB document payload (/tmp/large-test-doc.txt):

The primary focus of the report centers on the transition toward sustainable power generation, highlighting that *Solar and wind energy are leading global power grid decarbonization.* This shift relies on specific energy conversion mechanisms across renewable infrastructure systems. Specifically, solar power leverages photovoltaic cells to convert solar irradiance directly into electricity, whereas wind turbines harness kinetic energy from atmospheric airflow.

To maintain operational stability across power networks, energy storage solutions serve as an essential component for bridging intermittent generation with real-time consumer requirements. Advanced battery architectures, including both lithium-ion and flow battery systems, facilitate continuous frequency regulation and load shifting...
via model cli/agy

Tests & Verification

  • 23 vitest unit tests in tests/llm.cli.agy.test.ts passing 100%.
  • Verified via automated AI review bots on fork (mvance/summarize#19) with 0 unresolved issues.

@clawsweeper

clawsweeper Bot commented Sep 3, 2026

Copy link
Copy Markdown

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@clawsweeper clawsweeper Bot added P2 Normal priority bug or improvement with limited blast radius. merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 3, 2026
@clawsweeper

clawsweeper Bot commented Sep 3, 2026

Copy link
Copy Markdown

Codex review: blocked before merge. Reviewed September 4, 2026, 11:53 AM ET / 15:53 UTC.

ClawSweeper review

What this changes

This PR lets the Antigravity CLI summarize oversized text prompts by placing the document payload in a restricted temporary file and passing its file URL to agy --print.

Merge readiness

Blocked before merge - 3 items remain

Keep open for maintainer product-direction review: the implementation is technically coherent and has real CLI proof, but it deliberately changes the documented default from rejecting large or sensitive Agy prompts to transient local-file storage.

Priority: P2
Reviewed head: 96427514454ba6f384d70882f7603d760ee8d7da
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The patch is focused, well-covered, and backed by a real oversized-input run; its remaining blocker is the deliberate default-behavior policy choice.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): The changed production owner is the Agy runner; the contributor supplied a real summarize --cli agy --plain terminal trace on a 159 KB input that returned a summary after the runner supplied a temporary file URL, consistent with the introduced file-handling path.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The changed production owner is the Agy runner; the contributor supplied a real summarize --cli agy --plain terminal trace on a 159 KB input that returned a summary after the runner supplied a temporary file URL, consistent with the introduced file-handling path.
Evidence reviewed 4 items Current main retains the documented refusal: Current main rejects oversized Agy prompts before launch, and its CLI documentation tells users to use another provider for large or sensitive extracted content.
Introduced implementation: The PR writes an oversized payload to document.txt with mode 0o600, references it via a file URL, checks the reduced command length, and removes both temporary directories in finally blocks.
Behavior proof and regression coverage: The supplied contributor terminal trace shows a 159 KB summarize --cli agy --plain run returning a summary, while the introduced test suite covers payload separation, permissions, cleanup, Unicode handling, and command-size boundaries.
Findings None None.
Security None None.

How this fits together

Summarize formats extracted documents into tagged prompts and routes them to configured model CLIs. The Agy runner currently sends that prompt through --print; this change replaces oversized argv payloads with a local temporary document that Agy reads before returning the summary.

flowchart LR
  A[Extracted document] --> B[Prompt formatter]
  B --> C[Agy CLI runner]
  C --> D{Fits argv limit?}
  D -->|Yes| E[Agy print request]
  D -->|No| F[Restricted temporary document]
  F --> E
  E --> G[Summary output]
Loading

Decision needed

Question Recommendation
Should large and potentially sensitive Agy summaries be written to a temporary local file by default? Add an explicit opt-in: Keep the current default refusal and expose temporary-file offloading only through an approved, documented Agy setting.

Why: Current main intentionally refuses these inputs and documentation directs users to another provider, so the new storage behavior is a product and privacy-policy choice rather than a mechanical defect.

Before merge

  • Resolve merge risk (P1) - Merging changes existing Agy behavior for large and explicitly called-out sensitive content from a refusal to automatic transient local-file storage that an external CLI is instructed to read; existing users have no opt-in or migration choice.
  • Complete next step (P2) - Decide whether large and potentially sensitive Agy prompts may be automatically offloaded to a temporary local file by default.
  • Resolve maintainer decision - Resolve the maintainer decision shown above before merge.
Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Production versus test delta production +50 net lines, tests +385 net lines The new execution path has extensive focused boundary and cleanup coverage relative to its implementation size.
Affected files 3 files affected The change is confined to the Agy runner, its focused tests, and user-facing CLI documentation.

Root-cause cluster

Relationship: canonical
Canonical: #400
Summary: This PR is the active replacement for the closed, unmerged predecessor that offloaded the entire formatted prompt and caused meta-summarization.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge-risk options

Maintainer options:

  1. Require an opt-in storage policy (recommended)
    Keep the documented refusal as the default and add temporary-file offloading only after maintainers approve an explicit Agy configuration path.
  2. Accept the new default
    Approve automatic temporary-file storage as the supported Agy compatibility contract and make its privacy implications explicit in user documentation.
  3. Pause this direction
    Close or defer the proposal if the repository should not create local files for large Agy prompts.

Technical review

Best possible solution:

Preserve the documented refusal by default and, if temporary-file offloading is desired, introduce it behind a clearly documented opt-in after the privacy and compatibility policy is approved.

Do we have a high-confidence way to reproduce the issue?

Not applicable as a defect reproduction: current main intentionally rejects oversized Agy prompts, and the supplied terminal trace demonstrates the proposed new behavior on a 159 KB input.

Is this the best way to solve the issue?

Unclear: the implementation is narrow and proof-backed, but whether automatic storage is preferable to the current refusal requires an explicit maintainer privacy and compatibility decision.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against c0ddab5b8531.

Labels

Label justifications:

  • P2: This is a bounded CLI capability and compatibility decision with limited blast radius.
  • merge-risk: 🚨 compatibility: It replaces the documented large-prompt refusal with automatic temporary local-file storage for existing Agy users.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The changed production owner is the Agy runner; the contributor supplied a real summarize --cli agy --plain terminal trace on a 159 KB input that returned a summary after the runner supplied a temporary file URL, consistent with the introduced file-handling path.
  • proof: sufficient: Contributor real behavior proof is sufficient. The changed production owner is the Agy runner; the contributor supplied a real summarize --cli agy --plain terminal trace on a 159 KB input that returned a summary after the runner supplied a temporary file URL, consistent with the introduced file-handling path.

Evidence

What I checked:

  • Current main retains the documented refusal: Current main rejects oversized Agy prompts before launch, and its CLI documentation tells users to use another provider for large or sensitive extracted content. (src/llm/cli-runners/plain.ts:83, c0ddab5b8531)
  • Introduced implementation: The PR writes an oversized payload to document.txt with mode 0o600, references it via a file URL, checks the reduced command length, and removes both temporary directories in finally blocks. (src/llm/cli-runners/plain.ts:118, 96427514454b)
  • Behavior proof and regression coverage: The supplied contributor terminal trace shows a 159 KB summarize --cli agy --plain run returning a summary, while the introduced test suite covers payload separation, permissions, cleanup, Unicode handling, and command-size boundaries. (tests/llm.cli.agy.test.ts:303, 96427514454b)
  • Agy runner history: The existing Agy print runner dates to the merged runner change, while the current PR is an unmerged follow-up over that boundary. (src/llm/cli-runners/plain.ts:69, f87861c5e508)

Likely related people:

  • mvance: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Peter Steinberger: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Obtain a maintainer decision on whether temporary local-file storage should be opt-in or the new Agy default.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (5 earlier review cycles)
  • reviewed 2026-09-03T13:56:04.117Z sha 7c15efe :: needs real behavior proof before merge. :: [P2] Update the documented large-prompt behavior
  • reviewed 2026-09-03T15:48:19.639Z sha 9642751 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-03T18:33:32.738Z sha 9642751 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-04T00:21:05.444Z sha 9642751 :: blocked before merge. :: none
  • reviewed 2026-09-04T04:51:46.090Z sha 9642751 :: blocked before merge. :: none

@mvance

mvance commented Sep 3, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Sep 3, 2026

Copy link
Copy Markdown

🦞👀
Exact review queued.

Re-review progress:

@mvance

mvance commented Sep 3, 2026

Copy link
Copy Markdown
Contributor Author

Live Unmocked Execution Diagnostic & Behavior Proof

Here is the real, unmocked execution diagnostic running summarize --cli agy --plain against an oversized 159 KB input file (/tmp/large-test-doc.txt):

1. Input Document Generation & Environment Setup

$ python3 -c '
header = "# Comprehensive Report on Renewable Energy & Grid Integration\n\n"
body = "Solar and wind energy are leading global power grid decarbonization. Photovoltaic cells convert solar irradiance into electricity, while wind turbines harness kinetic energy. Storage technologies, particularly lithium-ion and flow batteries, play a critical role in balancing grid supply and demand.\n"
with open("/tmp/large-test-doc.txt", "w") as f:
    f.write(header + body * 500)
'
$ ls -lh /tmp/large-test-doc.txt
-rw-r--r-- 1 mvance staff 159K Sep  3 09:40 /tmp/large-test-doc.txt

2. Live Unmocked CLI Run

$ summarize --cli agy --plain /tmp/large-test-doc.txt

The primary focus of the report centers on the transition toward sustainable power generation, highlighting that *Solar and wind energy are leading global power grid decarbonization.* This shift relies on specific energy conversion mechanisms across renewable infrastructure systems. Specifically, solar power leverages photovoltaic cells to convert solar irradiance directly into electricity, whereas wind turbines harness kinetic energy from atmospheric airflow.

To maintain operational stability across power networks, energy storage solutions serve as an essential component for bridging intermittent generation with real-time consumer requirements. Advanced battery architectures, including both lithium-ion and flow battery systems, facilitate continuous frequency regulation and load shifting. As outlined in the documentation, *Storage technologies, particularly lithium-ion and flow batteries, play a critical role in balancing grid supply and demand.*

The integration of these renewable resources and storage systems forms a cohesive framework for modern electrical grid modernization and carbon reduction goals. By combining continuous kinetic and photovoltaic generation with scalable storage, power utilities can effectively manage fluctuations in generation. Consequently, the synthesis of solar arrays, wind generation, and battery storage represents the fundamental baseline for successful large-scale grid decarbonization.
via model cli/agy

29s · cli/agy

3. Real Agy Command & Temp File Inspection

  • Command Executed: agy --sandbox --print "Summarize the content in file:///tmp/summarize-agy-XXXXXX/summarize-agy-prompt-YYYYYY/document.txt\n\nIMPORTANT: Do not create or edit files. Do not include local file links or work-log narration. Return only the final text response."
  • File Permissions: 0o600 (-rw-------) on document.txt.
  • Payload Contained: Only raw document <content> text (159 KB).
  • Argv Contained: <instructions>, <context>, and file URL reference.
  • Directory Cleanup: Verified /tmp/summarize-agy-prompt-* directory was automatically deleted after exit.

@mvance

mvance commented Sep 3, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Sep 3, 2026

Copy link
Copy Markdown

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added proof: sufficient Contributor real behavior proof is sufficient. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. and removed merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Sep 3, 2026
@steipete

steipete commented Sep 5, 2026

Copy link
Copy Markdown
Owner

Autonomous triage update: the installed agy fails a synthetic readiness probe with authentication required. Run 'agy' to log in, then retry. Independent large-document verification is therefore blocked; no source changes or merge were made.

The contributor's successful 159 KB trace is useful, but the remaining acceptance step is to verify instruction retention, output, and cleanup through the built CLI with a usable authenticated agy session, then decide whether automatic temporary-file offloading should become the default for oversized prompts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. P2 Normal priority bug or improvement with limited blast radius. proof: sufficient Contributor real behavior proof is sufficient. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants