Skip to content

fix(chat): handle long prompts across Agent CLIs - #1267

Merged
Robert0622 merged 9 commits into
mainfrom
codex/fix-dsh-long-prompts
Nov 25, 2026
Merged

Robert0622 merged 9 commits into
mainfrom
codex/fix-dsh-long-prompts

Conversation

@Robert0622

@Robert0622 Robert0622 commented Nov 23, 2026 •

Copy link
Copy Markdown
Collaborator

What changed

  • Use the same 96 KiB cutoff for assembled chat prompts across Agent CLIs. Long prompts leave the command line before the process starts.
  • Use native stdin for DeepSeek Harness, OpenCode, and Pi, Antigravity's NDJSON input, and Cursor's ACP input. Use one staged-file path for Kimi Code's prompt hook and ZCode's text attachments.
  • Preserve Kimi Code's native system profile and approval hook. Keep ZCode's attachment parts below its per-file preview budget and relocate conversation paths for runner execution.

Fixes #434 and #1081. Related to #429.

  • Filter Cursor Auto routing notices consistently and let ACP turns finish once the CLI returns its final reply.

Compatibility

Short prompts use each CLI's original launch mode until a Cursor conversation enters ACP. Subsequent turns in that Cursor conversation reuse ACP and its native history. When Cursor cannot open a print-mode journal in ACP, LoopForge uses its existing transcript replay to start the ACP session. The tested Cursor version reports token usage in print mode and omits it over ACP.

Older remote runners report an upgrade requirement for long Kimi Code and ZCode turns because these modes synchronize temporary prompt files.

Validation

  • Focused Go regression tests passed for executor argument construction, stdin and ACP delivery, runner asset remapping and cleanup, and short-prompt compatibility. The original dsh runner regression also covers a prompt over 1 MiB.
  • Actual dsh, OpenCode, Pi, Kimi Code, and ZCode CLIs opened and resumed chats with approximately 140 KB synthetic prompts and received replies from DeepSeek. Kimi Code also passed short and long turns in both orders with its custom system instructions present.
  • Actual Antigravity opened and resumed chats with approximately 132 KB synthetic prompts. The gateway used a long-context model alias and forwarded to DeepSeek. Antigravity's own context budget still applies.
  • Actual Cursor returned both markers from a synthetic prompt over 140 KB. The same session retained the reply through long and short follow-ups and each completed turn released its process. A legacy print session returned its original fixture label after LoopForge rebuilt the transcript for ACP.
  • Actual Cursor used an isolated MCP fixture and reached the native approval callback. Regression tests covered standalone short prompts, attachments, credentials, approvals, cancellation, and the Cursor reply stream.
  • go vet ./..., the public-content check, and the secret scanner passed.

Safety

  • I did not include credentials, internal endpoints, production data, or organization-specific infrastructure.
  • I preserved user files and unrelated changes.

crispinhu27
crispinhu27 previously approved these changes Nov 23, 2026

@crispinhu27 crispinhu27 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed at head 04e8eef0 (base main 4ff0e73, merge-base 88255b7). This is the first review.

Scope: the dsh branch of AgentCLICommand, plus the code that consumes CommandSpec.Stdin:

  • AgentCLITaskPrompt, positionalPrompt and PromptOnStdin
  • chat execution through assistant_engine_agentcli → ConversationCommandFor(...).Interactive → the assistant_process write/EOF pump, including the runner path remap
  • local sandbox_local and Docker exec -i
  • the dsh native-approval --patch insertion and applyDeepSeekCredential argv splicing, which still operate on argv[:3]

Verification: run in an isolated user, with no repository credentials and synthetic data only.

  • go build ./... and go vet ./internal/runtime ./internal/httpapi pass.
  • The new tests TestDeepSeekOversizedPromptReachesCLIOnStdin (fresh and resume) and TestDeepSeekShortPromptUsesPositionalArgument pass. With the same test file on the merge-base, both subtests fail with fork/exec …/dsh: argument list too long, so the regression is real and this PR fixes it.
  • End-to-end with the real @deepseek-ai/dsh@0.2.2-rc.5. The probe builds the chat command with AgentCLICommand(dsh, Chat:true, …) and a 162,019-byte prompt, then runs it with ExecuteLocalCommand and BindAgentCLI against a local mock OpenAI-compatible endpoint.
    • Head: dsh starts, and the mock receives the complete prompt (one 186,540-byte request containing the tail marker). The run then finishes with final … "text":"MOCK_REPLY_OK".
    • Merge-base: the same probe fails before start with argument list too long.
  • go test ./internal/httpapi -run 'AgentCLI|DeepSeek|DSH|Stdin|OversizedPrompt|ConversationProcess|AssistantEngine' passes.
  • go test ./internal/runtime (full package): the remaining failures are environment-related and appear identically on the merge-base. They are the Chromium browser tests, TestEnvironmentIdentityGitAndMCPHeaders and TestBwrapMountsManagedInstallationUnderPrivateTmp. The Docker-helper tests that failed under the full parallel run pass when run alone on both head and base.
  • All CI checks on this head are green, including core.

Not separately verified:

  • A real-dsh resume turn. Resume is covered by the PR's fake-CLI test, and it uses the same headless stdin path.
  • A real remote runner or Docker run. Both use the existing stdin transport, which Claude Code and CodeBuddy already rely on.

No blocking issues found.

@Robert0622 Robert0622 changed the title fix(runtime): send oversized dsh prompts on stdin fix(chat): handle long prompts across Agent CLIs Nov 23, 2026

@crispinhu27 crispinhu27 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review at head 41b0df7a (base main 4ff0e73, merge-base 88255b7). The earlier APPROVE on 04e8eef0 (review 6023140337) was dismissed by the new push. This review covers the whole PR, with a focus on the new commit 41b0df7a, which extends long-prompt handling to all Agent CLIs.

Scope:

  • agentCLIPromptInput and StageAgentCLIConversationCommand: stdin for dsh, OpenCode and Pi; NDJSON for Antigravity; staged prompt files for Kimi (UserPromptSubmit hook) and ZCode (16 KiB attachments).
  • The ACP client in assistant_engine_acp.go and the Antigravity keep-open input.
  • The local runAssistantCLI path and the conversationExecutor path, including prompt-input asset sync/rewrite, runner remap/cleanup, the PromptInputFiles upgrade gate and ConversationTextChunkLen.
  • Antigravity --settings insertion when -p is absent.

Verification: isolated workspace, synthetic data only, local mock OpenAI-compatible endpoint, no repository credentials.

  • go build ./... and go vet ./... pass.
  • Focused runtime/httpapi tests pass, including the new TestAgentCLIConversationLongPrompt, TestAgentCLIConversationShortPromptUsesArgv and TestAssistantACPConversationInput.
  • Full go test ./internal/httpapi ./internal/runtime: the failing tests are identical on head and merge-base. They are the Chromium/browser, Docker, bwrap and git-identity tests, which are environment-related.
  • Real CLIs, 170,016-byte chat prompt with a tail marker:
    • On head, the mock receives the complete prompt (tail marker present) and the CLI replies for dsh 0.2.2-rc.5, OpenCode 1.19.6, Pi (@earendil-works/pi-coding-agent) and Kimi Code 2.7.2 (through the UserPromptSubmit hook file).
    • On merge-base, all of these fail with argument list too long.
  • Antigravity, through the real chat invocation: the NDJSON frame is delivered, the result is translated, and the process exits after closeWriter, both new and resumed. This holds with long-context model aliases. With short-context aliases, Antigravity itself rejects the prompt (no messages fit within the context token budget), as the PR description notes.
  • prompt-input staging is removed after each turn.
  • CI on this head is green, including core and the re-run browser job. The first browser failure was desktop settings navigation reopens on the current page (a focus assertion); the PR touches no web code, and the same test also failed on unrelated commit ca11d64.

Blocking issue: one P2, inline. A long-prompt Cursor (ACP) turn does not finish, because cursor-agent acp ignores stdin EOF.

Not verified:

  • A successful Cursor ACP prompt (needs a Cursor account).
  • ZCode with a real CLI (not installable here).
  • A real remote runner or Docker run.
  • Resume turns with real dsh/OpenCode/Pi/Kimi; these are covered by the PR's unit tests.

crispinhu27
crispinhu27 previously approved these changes Nov 23, 2026

@crispinhu27 crispinhu27 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review of head 7e62c3d3 (base main 4ff0e73c, merge-base 88255b7e). The increment since my last review (41b0df7a) is f7cf3407 and 7e62c3d3.

Previous finding

  • [P2] Long-prompt Cursor ACP turns never finish because cursor-agent acp ignores stdin EOF: FIXED. I re-tested it with the real Cursor CLI and with a fake ACP peer that lingers after EOF, on both the local executor and the local conversation-process executor. Turns now end about 2.5 s after the terminal ACP result. Before this change they ran until the 90 s probe deadline. Details are in the thread.

Reviewed in this increment

  • assistantACP.execute: drain-then-cancel after the result. A user cancellation is still reported as an error, and result() runs only once because translate returns early when stream.Finished().
  • Cursor ACP transport pinning: the cursor-acp: entry in agent-cli-sessions.json, CursorACP in agentCLIPromptInput, and ACPPrompt *string.
  • CursorRouteFilter applied to ACP answer chunks, and the model ID taken from session/new.

Validation

  • go build ./... and go vet ./internal/httpapi ./internal/runtime pass.
  • Focused tests pass: httpapi ACP|Cursor|AgentCLI|LongPrompt and runtime AgentCLI|Cursor|Conversation|Prompt.
  • Full internal/httpapi and internal/runtime runs: the only failures are browser, Docker, bwrap and git-identity tests. The same tests fail on merge-base in this sandbox, so they are environmental.
  • Multi-turn probe with a fake Cursor CLI: short print turn → long ACP turn (session/load of the print session) → two short follow-ups. The follow-ups stay on ACP with the same native session, and each turn completes.
  • CI: everything is green except the browser job. Its one failure is ui/03-workbench-settings.spec.mjs:103 (desktop settings navigation focus). This PR does not touch web/, e2e/ or chatbot/. The same test passed on 41b0df7a, whose frontend is identical, and it failed on its own in unrelated PR runs 45165195194 and 45168175968. It looks like an existing flake. A re-run of that job should clear platform-required.

Not verified: a successful real Cursor ACP turn (no Cursor account), the remote runner and Docker execution paths, and real ZCode/Kimi CLIs for this increment.

@cocofhu00

Copy link
Copy Markdown
Contributor

结论:需要修改

GitHub 拒绝了 Pull Request Review 接口(HTTP 403:Tencent 组织启用了 OAuth App 访问限制)。当前账号对 LoopForge 只有 pull 权限,无法提交正式 Approve / Request changes。以下改为普通评论。

长提示词主线与 #434、#1081 是对得上的:超过 96 KiB 时 DeepSeek / OpenCode / Pi 走 stdin,Cursor 走 ACP,Antigravity 走 NDJSON,Kimi 与 ZCode 走暂存文件,并有回归测试。CI 16 项成功,也没有和 main 冲突。但最新提交把与这两条 issue 无关、描述里也没说明的设置导航改动夹进来了,需要先拆出去。

  1. web/app.js 第 1019–1021 行、第 1767 行、第 1811–1814 行:#settingsSidebarExpand 在展开前同步把焦点转到 #settingsSidebarToggle。这是设置侧栏的焦点修复,不参与提示词传递。
  2. web/app/navigation.css 第 259 行、第 271–273 行:收起和进入动画去掉了 visibility。侧栏收起时虽然有 inert,但这仍是另一处界面行为。
  3. e2e/ui/03-workbench-settings.spec.mjs:只覆盖上述焦点,不覆盖长提示词。

请把提交 917b176cb3 的这三个文件拆到独立 PR,或在描述中说明它和长提示词修复的关系后再合入本 PR。提示词路径可以保留。

crispinhu27
crispinhu27 previously approved these changes Nov 23, 2026

@crispinhu27 crispinhu27 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

复审(增量 7e62c3d..917b176):APPROVE

本轮审查范围:7e62c3d3 上的 APPROVE 之后新增的提交 917b176「fix(web): keep focus when reopening settings navigation」(web/app.js、web/app/navigation.css、e2e/ui/03-workbench-settings.spec.mjs)。我读了 setSettingsSidebarExpanded 的全部调用方、路由切换过渡逻辑和设置导航的 CSS,确认这次增量和 PR 其余部分(CLI / 对话改动)没有交叉。

验证(隔离环境,head 917b176,对照 7e62c3d):

  • webtest 下 npm test:230/230 通过;go test ./web/...:147 个通过,唯一失败的 TestNativeChatLazyImportsAreEmbedded 是因为本地没有构建 chatbot 产物,和本 PR 无关(CI core 为绿)。
  • 用本地静态服务加 Chromium(Playwright)跑新的 03-workbench-settings 用例(重复 31 次):head 全部通过。旧 head 上,原来那条“焦点最终落到收起按钮”的断言 31 次里失败 3 次,复现了上一轮 browser 任务的偶发失败;新代码在所有重复运行中都没有再出现。
  • 补测:鼠标点击、空格键重开导航,以及焦点在 body 上时重开,焦点都会落到收起按钮;焦点在主内容区时重开不会抢焦点;收起后侧栏是 inert、点不到,Tab 键进不去;900px 抽屉模式正常;1440/900 两种宽度下开、合状态的截图和旧 head 逐像素一致。
  • 当前 head 的 16 项 CI 全部 success。

非阻塞备注:收起后侧栏改用 clip 隐藏,不再设 visibility: hidden,所以 e2e 里 expect(collapse).toBeVisible() 已经不能证明侧栏重新打开了,不过 aria-hidden 和焦点断言仍然覆盖了这个行为。未验证:真实 Safari 和读屏软件,以及在完整后端上跑真实 e2e(本地缺 MySQL/Docker;CI 的 browser 和 e2e-browser 已在该 head 上通过)。

此前的阻塞问题(ACP 长 prompt 进程挂住)已在 7e62c3d 上复测为 FIXED,线程已解决;本次增量没有动相关代码。

roberttwang and others added 3 commits November 24, 2026 15:36
This reverts commit 917b176.
The settings navigation focus fix is unrelated to long prompt handling
and moves to its own pull request.

Co-Authored-By: Claude Code <noreply@anthropic.com>
Keep main's workspace-aware stdin chunk boundaries and route them through
the shared runtime.ConversationTextChunkLen used for staged prompt files.

Co-Authored-By: Claude Code <noreply@anthropic.com>
Co-Authored-By: Claude Code <noreply@anthropic.com>
@Robert0622

Copy link
Copy Markdown
Collaborator Author

已按 cocofhu00 的意见拆分,并合入最新 main,head 现为 34529d06。

  • 0fced5fb revert 了与长提示词无关的 917b176(设置导航焦点)。这三个文件的改动已移到独立 PR fix(web): keep focus when reopening settings navigation #1311。现在本 PR 相对 main 只剩 14 个 Go 文件。核对过:长提示词相关测试都不依赖它。
  • 309ece75 / 34529d06 合入 main(到 177d8815)。冲突在 internal/httpapi/assistant_process.go:main 新增了切分 stdin 时避开会话根目录和 <root>/ws 路径(Codex 用 JSON 编码路径);本 PR 把切分函数移到了 runtime.ConversationTextChunkLen,供 Kimi/ZCode 暂存文件共用。两边都保留,签名改为 ConversationTextChunkLen(data string, limit int, paths ...string),provider_agentcli.go 调用方同步修改。

验证

  • go build ./...、go vet ./... 通过;runtime/httpapi 中长提示词、ACP、Cursor、对话进程相关测试全过;两包全量与 main 失败集合一致(TestChatClarificationEdgePaths 为已有偶发,单独重复 60 次 main 与本分支各失败 4 次)。webtest 284/284,chatbot vitest 487/487。
  • 真实 CLI,本分支原生部署实例,经 /api/assistant/chat 发 140,320 字节合成提示词(首尾各一个标记):
    • dsh 0.2.2-rc.5(DeepSeek flash):长提示词首轮两个标记都答对,短追问续聊正确。
    • Cursor CLI 2026.11.22(grok-4.7 high):长提示词走 ACP 答对;之后的短追问仍在 ACP、同一原生会话;每轮结束后 cursor-agent 进程退出;session/load 回放的历史在会话 ID 设置前到达,被正确忽略,没有混进回答。
    • 先短后长的 Cursor 会话:长提示词那轮换成新原生会话,前面让它记住的口令仍能带出(与描述中的转录回放一致)。
    • 对照:main 二进制发同样提示词,dsh 和 Cursor 都报 fork/exec …: argument list too long。
  • 未覆盖:OpenCode/Pi/Kimi/ZCode/Antigravity 真实 CLI(只有 PR 自带的假 CLI 回归测试)、远程 Runner、Docker 执行路径。

crispinhu27
crispinhu27 previously approved these changes Nov 24, 2026

@crispinhu27 crispinhu27 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review of head 34529d06 (base main 177d881). My earlier APPROVE on 917b176c was dismissed by the new push. New since then: 0fced5fb reverts the settings-nav focus change (moved to #1311), and 309ece75 / 34529d06 merge main.

Scope

  • The PR now changes 14 Go files against main and no web files, so the revert is clean.
  • I compared this PR's own changes in those 14 files at the approved head and at the current head. The only difference is that runtime.ConversationTextChunkLen(data string, limit int, paths ...string) now takes several paths (main's multi-path logic moved in unchanged), and its two callers were updated to match.
  • Codex stdin still calls conversationInputChunkLen(data, workspacePath, rootPath) and goes through runtime.ConversationStdinPath, so main's handling of both the encoded root and <root>/ws is kept.
  • Kimi/ZCode staged files (provider_agentcli.go stageText) split around i.root. The runner's sync for prompt-input/ only maps the session root, so this is enough.

Verification (offline sandbox, no real Agent CLI or model credentials):

  • go build ./... and go vet pass. go test ./...: the head and the base each have 27 packages passing. The 127 failing tests are the same set on both (comm finds no difference). They need bwrap, Chromium or Docker.
  • The long-prompt and chunking tests pass, including:
    • TestAgentCLIConversationLongPrompt and TestAgentCLIConversationShortPromptUsesArgv
    • the DeepSeek stdin tests, TestAssistantACP* and TestAssistantCursorShortResumeKeepsItsTransport
    • TestConversationImageInputChunkPreservesRemotePathAndUTF8 and TestConversationInputChunkPreservesEncodedWorkspacePath
  • A temporary harness (not committed) checks the staged files end to end.
    • Setup: for ZCode and Kimi, it builds a ~300 KB prompt with session-root, ws/ and attachments/ paths placed across 16 KiB chunk boundaries at 29 offsets, stages it with StageAgentCLIConversationCommand, and moves it to a new root through ConversationProcessPool.Handle (sync).
    • Result: the reassembled text exactly equals the prompt with every path remapped, so it passes.
    • Negative control: with the path argument removed from stageText, the harness fails (residual src refs=15).
  • CI: all 16 checks pass at this head.

Not covered: real CLI runs and macOS seatbelt runners. Non-blocking note, not from this merge and not reproduced: Antigravity and Cursor ACP stdin frames are JSON but don't go through ConversationStdinPath, so a session root containing ", \, <, > or & would not be remapped. Ordinary paths are unaffected.

I found no blocking issues, so I'm approving.

@cocofhu00

Copy link
Copy Markdown
Contributor

结论:建议合入

GitHub 拒绝了 Pull Request Review 接口(HTTP 403:Tencent 组织启用了 OAuth App 访问限制)。当前账号无法提交正式 Approve / Request changes。以下改为普通评论。

对照了 #434 和 #1081。internal/runtime/provider.go 的 maxArgvPromptBytes 是 96KiB,低于 Linux 单参数约 128KiB 的限制。超长提示在 agentCLIPromptInput 里离开 argv:OpenCode、Pi、DeepSeek 走 stdin,Cursor 走 ACP,Antigravity 走 NDJSON,Kimi 和 ZCode 走临时文件;短提示仍用原来的参数形式。internal/runtime/agent_cli_prompt_test.go 等回归覆盖了这些路径。#429 只作相关说明,本 PR 没有声称关闭它。与 main 无冲突,检查项均成功。可以合入。

@Robert0622 Robert0622 left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CR + 部署实测(head 34529d06):LGTM

说明:这次评审的 token 是 PR 作者本人的账号,GitHub 不允许作者 approve 自己的 PR,所以只发评论、不点 Approve。

部署实测(本机原生部署 PR 和 main 两个实例,MySQL 8.4.7 全新库,真实 CLI 和模型)
提示词约 195KB(单个参数超过内核 128KiB 上限),开头和结尾各放一个暗号,要求模型把两个暗号都复述出来;然后追问一轮「开头的暗号数字是多少」,验证会话能续上。

CLI / 模型 PR 长提示词 PR 追问一轮 main 长提示词
DeepSeek dsh / deepseek-flash ✅ ALPHA-7319 OMEGA-4826(10s) ✅ 7319 ❌ 4s 失败:argument list too long (a single argument exceeds the ~128KiB kernel limit…)
Cursor cursor-agent / grok-4.7 high(走 ACP) ✅ 两个暗号都对(30s) ✅ 7319,长提示词之后的会话继续走 ACP ❌ 4s 失败,原因同上
CodeBuddy / deepseek-v4.1-flash ✅(12s) ✅ ✅(main 上本来就走 stdin)

另外单独验证了 ACP 下的权限请求:用 cursor-agent --trust --force --approve-mcps acp 让模型执行 shell 命令,Cursor 没有发 session/request_permission,命令照常执行、stopReason=end_turn。所以 assistant_engine_acp.go:175 对权限请求一律回 cancelled,在 --force 下目前碰不到。不过按 ACP 规范,cancelled 的意思是「整轮被取消」;如果以后去掉 --force,建议改成回 reject_once。

代码审查

  • stdin、stdout、stderr 并发处理,大段 stdin 不会把管道写死;取消时 Close 能唤醒阻塞的 Write,不会泄漏进程或协程。
  • 临时提示词文件写在 root/prompt-input/turn-*(目录 0700、文件 0600),不在工作区里,不会被提交,本地和远端都会清理。
  • 96KiB 以内的提示词仍走 argv,行为不变。
  • 与 main f3d4f41a 合并无冲突;设置导航那个提交已经 revert,移到了 #1311,净 diff 里没有 web 改动。

建议(P3,不阻塞):internal/runtime/conversation_process.go:996 ConversationStdinPath 只对 codex 按 JSON 转义路径。现在 Cursor ACP 帧和 agy 的 stream-json 帧也是 JSON;如果远端执行机是 Windows(路径里有 \),替换进去的路径会变成非法转义。目前没有 Windows 执行机的话可以先不管。

回归:go test ./internal/httpapi/ ./internal/runtime/ -run 'ACP|Prompt|DeepSeek|Cursor|LongPrompt' 通过;httpapi/runtime/repo/runeval 四个包,失败项与 main 完全相同(26 项,本机缺 Docker、bwrap、Chromium 等),没有新增失败;chatbot vitest 487/487。工具调用类的端到端场景本机跑不了(会话工作区要 Docker),main 上也一样。

结论:没有发现阻塞问题,可以合入。

@Robert0622

Copy link
Copy Markdown
Collaborator Author

关于上次评审里那条 P3(Windows 执行机上的路径进入 stdin JSON 帧会变成非法转义):核对后不成立,不需要改。

  • 执行机不支持 Windows。GOOS=windows go build ./cmd/agentflow-runner 在本 head 34529d06 上编译失败(internal/gitwork/repository_cache.go 用了 syscall.Flock,internal/preview/archive.go 用了 syscall.Stat_t),scripts/build-binaries.sh 也只产出 linux 和 darwin。
  • linux / darwin 的路径里没有 \,JSON 编码后和原文一致,替换结果不变。

等真的要支持 Windows 执行机时再一起处理。

Resolve the ConversationProcessResult conflict by keeping both the
WorkingDir/PromptInputFiles fields from this branch and ErrorCode from
#1318.

Co-Authored-By: Claude Code <noreply@anthropic.com>

@crispinhu27 crispinhu27 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review of head 571ab388 (base main 848793b). My APPROVE on 34529d06 was dismissed by this push. The only new commit is 571ab388, which merges main (7 commits since 177d8815, including #1318's workspace-CLI fallback).

Scope

  • I compared this PR's own changes against main at the previously approved head (177d8815...34529d06) and at the current head (848793b3...571ab388). The same 14 Go files change, with no web files. The only difference is the merge resolution in internal/runtime/conversation_process.go: ConversationProcessResult keeps main's new ErrorCode field next to this PR's WorkingDir and PromptInputFiles, and the column alignment changes. The PR doesn't drop or revert anything from main.
  • Main and this PR both touch assistant.go, assistant_process.go and conversation_process.go. I read the merged code. #1318's mode switching and workspaceStartFailed prompt live in chat's generate. This PR's ACP execution wrapper lives in runAssistantCLI, and its PromptInputFiles / WorkingDir handling lives in conversationExecutor. They change different code paths, and ErrorCode still reaches the runner control response.

Verification (isolated sandbox, synthetic data, no real Agent CLI or model credentials)

  • go build ./... and go vet ./internal/httpapi/ ./internal/runtime/ pass.
  • go test ./internal/runtime/... ./internal/httpapi/... ./internal/runner/... on head and on main: every test that failed on head without also failing on main falls into one of two groups:
    • Missing bwrap: 8 cases, including TestWorkspacePreparationAPISeparatesReadersAndWriters and TestGenericTemplatesAndCopiesRunWithoutRepository. They fail with bwrap sandbox unavailable on both. I reran them 3 times on each side and they failed every time.
    • TestChatClarificationEdgePaths: panics intermittently with index out of range on both main and head. That's existing flakiness.
  • Focused runs pass: long and short prompts, DeepSeek stdin, TestAssistantACP*, Cursor short resume, conversation input/image chunking, ConversationProcess*, and main's new WorkspaceFallback* / ResumeRecovery* tests on this head.
  • CI: all 16 checks pass at this head.
  • Previous issues: the only thread from my reviews (the [P2] where long-prompt Cursor turns never finish after the ACP exchange ends) was already verified FIXED and resolved in an earlier round. The ACP code didn't change in this merge.

Not covered: real CLI runs and macOS seatbelt runners, same as the previous review. The end-to-end staging harness from the previous round wasn't rerun because the staging code is unchanged.

I found no blocking issues, so I'm approving.

@Robert0622

Copy link
Copy Markdown
Collaborator Author

main 前进到 848793b3(#1319、#1318)后本 PR 有冲突,已合入 main,head 现为 571ab388。

验证

  • go build ./...、go vet 通过;internal/runtime、internal/runner、internal/httpapi 全量跑完,失败用例与 main 848793b3 在同一环境下的结果完全一致(都是本机缺 Docker / Chromium),没有新增失败。CI 16/16 通过。
  • 本机部署实测(MySQL 8.4.7 全新库,平台和执行机器都用本 head 构建;没有对本仓库做实测):
场景 结果
平台执行,Claude Code + DeepSeek deepseek-flash,短提示 正常回复
同一会话追加约 260 KB 长提示(超过 96 KiB 阈值) 回复里同时有开头和结尾标记
同一会话再发短追问 正确回答上一条的结尾标记,续接正常
平台执行,Cursor CLI grok-4.7 high,约 260 KB 长提示(走 ACP) 两个标记都返回
同一 Cursor 会话短追问 复用 ACP 会话并正确回答
个人执行机器(本 head 构建的 runner 0.12.4)上,Cursor grok-4.7 high 长提示 两个标记都返回;执行机器走 conversationProcess,WorkingDir 正常传回
回合结束后检查进程 没有残留的 CLI 进程

@Robert0622

Copy link
Copy Markdown
Collaborator Author

Re-review of 571ab388 (merge of main 848793b3): the conflict resolution is correct, and long prompts work in a real deployment with real CLIs. LGTM.

Code

  • The only conflict is in internal/runtime/conversation_process.go, ConversationProcessResult. The resolution keeps this PR's WorkingDir / PromptInputFiles and fix(chat): fall back when the workspace CLI cannot start #1318's ErrorCode, and only changes column alignment (git show --remerge-diff 571ab388). Nothing from main is dropped.
  • In the merged code, ErrorCode is still filled in from proc.errorCode (conversation_process.go:369) and read by the not-started branch in assistant_process.go:445. PromptInputFiles (the gate for remote runners at :300) and WorkingDir (the ACP cwd at :361) are used on separate paths.
  • Trial merge with current main 1cbaa4a4 (feat(im): 把聊天发起人记入需求操作日志,并在平台管理里配置外部访问地址 #1300): no conflicts. On the merge, go build ./... passes, go vet on httpapi/runtime/repo is clean, and the httpapi (ACP/Prompt/DeepSeek/Cursor/WorkspaceFallback/ResumeRecovery/Clarify) and runtime (Prompt/Conversation/Stdin/Chunk) tests pass.

Deployment test

  • Setup: this head and main 1cbaa4a4, each with its own fresh MySQL 8.4.7 database, real CLIs, and a native sandbox. Not tested against this repo.
  • Prompt: ~194 KB (194430 bytes, more than the ~128 KiB single-argument limit). It puts a codeword at the start and one at the end, and asks the model to repeat both. A follow-up turn then asks for the number in the start codeword.
CLI / model PR long prompt PR follow-up main long prompt
DeepSeek dsh 0.2.2-rc.5 / deepseek-flash ✅ ALPHA-7319 OMEGA-4826 (3 s) ✅ 7319 (3 s) ❌ 502. The server log shows fork/exec … argument list too long (a single argument exceeds the ~128KiB kernel limit…)
Cursor cursor-agent 2026.11.22 / grok-4.7 high ✅ both codewords (30–63 s) ✅ 7319 (15 s) ❌ same error

I also ran a ~194 KB prompt in a session that was switched to workspace mode and fell back to platform mode: 200, both codewords correct.

Not covered

Conclusion: no blocking issues, OK to merge. This token is the PR author's account, so this is a comment, not a formal approval.

@Robert0622
Robert0622 merged commit b17639d into main Nov 25, 2026
16 checks passed
@Robert0622
Robert0622 deleted the codex/fix-dsh-long-prompts branch November 25, 2026 13:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] DeepSeek 聊天长历史在启动 CLI 前触发 E2BIG(argument list too long)

3 participants