Skip to content

fix(chat): send oversized pi prompts over stdin - #1115

Open
vastStage wants to merge 1 commit into
Tencent:mainfrom
vastStage:fix/pi-long-chat-stdin
Open

vastStage wants to merge 1 commit into
Tencent:mainfrom
vastStage:fix/pi-long-chat-stdin

Conversation

@vastStage

@vastStage vastStage commented Nov 19, 2026 •

Copy link
Copy Markdown

What changed

A chat turn on the pi agent CLI embeds the whole conversation in the prompt. Once that prompt passes maxArgvPromptBytes (96 KiB), AgentCLICommand still appended it as a positional argv argument, so fork/exec failed with E2BIG (argument list too long) before the CLI started; every retry rebuilt the same oversized argv.

Pi reads the prompt from stdin when no positional prompt is given. For chat turns with an oversized prompt, this change now leaves argv prompt-free and sets CommandSpec.Stdin instead. The existing conversation pipeline already forwards Stdin to the native process, so the complete prompt reaches Pi without EOF.

SOP turns keep their current positional form: they write the task prompt to a file and positionalPrompt substitutes a short reference when it is oversized, so their argv shape is unchanged.

Fixes #1081.

Scope

  • Platform core / API / runner
  • Public adapter / deployment
  • Classic
  • Portable
  • Shared behavior contract
  • Installer / CLI
  • Documentation only

Compatibility

Affected host: any platform/runner running Pi chat (pi agent CLI provider). No API, schema or runner-protocol change. Short chat prompts, resumed sessions, SOP invocations and all other providers keep their existing argv. No migration required.

Validation

Commands actually run (Windows host, Linux target; tests executed in WSL Ubuntu 24.04):

GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go vet ./internal/runtime        # pass
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build ./...                  # pass
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go test -c -o runtime.test ./internal/runtime
runtime.test -test.run 'TestAgentCLIPiOversizedChatPromptUsesStdin|TestAgentCLIPiSOPPromptStaysOnArgv|TestAgentCLICommandChatRestrictions|TestPromptOnStdin' -test.v  # all pass

New regression tests:

  • TestAgentCLIPiOversizedChatPromptUsesStdin: the prompt leaves argv, arrives byte-for-byte on stdin.
  • TestAgentCLIPiSOPPromptStaysOnArgv: the SOP path is unchanged.

The rest of the internal/runtime suite passes apart from 5 environment-related failures outside this diff. Four gate-MCP tests need a go binary in WSL PATH. TestDockerfileBundlesTheOnDemandDeepSeekHarnessRelease fails only because the Windows checkout stores the Dockerfile with CRLF (...dsh@0.2.2-rc.1\r\n), while the assertion expects LF; the Linux CI checkout is LF and this test is untouched by the PR.

Not run: repository-level go test -p=2 ./..., browser acceptance suite, real Pi model/API turn.

Safety

  • I did not include credentials, internal endpoints, production data, or organization-specific infrastructure.
  • I preserved user files and unrelated changes.
  • I updated generated Classic host bundles when applicable. (Not applicable.)
  • I documented third-party content and licensing changes when applicable. (Not applicable.)

Pi reads the prompt from stdin when no positional prompt is given. A chat turn embeds the whole conversation, so once the prompt passes maxArgvPromptBytes keeping it on argv makes fork/exec fail with E2BIG before the CLI starts. SOP turns still use the prompt-file fallback and keep the positional form.

Refs Tencent#1081
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]: pi provider 长对话触发 E2BIG(argument list too long),CLI 无法启动

1 participant