Use --prompt-file for Copilot execution and add Copilot driver fallback handling#26492
Use --prompt-file for Copilot execution and add Copilot driver fallback handling#26492
--prompt-file for Copilot execution and add Copilot driver fallback handling#26492Conversation
…imits Agent-Logs-Url: https://github.com/github/gh-aw/sessions/43f03841-a79f-42f0-8065-3a0a2bc6f26e Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>
Agent-Logs-Url: https://github.com/github/gh-aw/sessions/43f03841-a79f-42f0-8065-3a0a2bc6f26e Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>
--prompt-file for Copilot execution to avoid ARG_MAX failures on large prompts
This comment has been minimized.
This comment has been minimized.
1 similar comment
|
Hey A couple of things to address before this is ready for review:
If you'd like a hand, you can assign this prompt to your coding agent:
|
|
Hallucination? |
There was a problem hiding this comment.
Pull request overview
Updates Copilot CLI command generation to avoid Linux ARG_MAX failures by passing the prompt via a file path (--prompt-file) instead of inlining prompt content into a single argv entry.
Changes:
- Switch Copilot invocation (AWF + non-AWF paths) from
--prompt "$(cat ...)"/--prompt "$VAR"to--prompt-file /tmp/gh-aw/aw-prompts/prompt.txt. - Remove the non-AWF shell variable assignment that loaded the prompt content into
COPILOT_CLI_INSTRUCTION. - Update Copilot engine tests and WASM golden fixtures to assert the new generated command form.
Show a summary per file
| File | Description |
|---|---|
| pkg/workflow/copilot_engine_execution.go | Generate Copilot command using --prompt-file and remove inline prompt expansion/variable assignment. |
| pkg/workflow/copilot_engine_test.go | Update assertions to require --prompt-file usage and absence of COPILOT_CLI_INSTRUCTION=. |
| pkg/workflow/testdata/TestWasmGolden_CompileFixtures/basic-copilot.golden | Refresh golden output to reflect --prompt-file in generated workflow. |
| pkg/workflow/testdata/TestWasmGolden_CompileFixtures/with-imports.golden | Refresh golden output to reflect --prompt-file in generated workflow. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 4/4 changed files
- Comments generated: 2
| if sandboxEnabled { | ||
| // Sandbox mode: add workspace dir and inline prompt (read inside AWF container) | ||
| copilotCommand = fmt.Sprintf(`%s %s --add-dir "${GITHUB_WORKSPACE}" --prompt "$(cat /tmp/gh-aw/aw-prompts/prompt.txt)"`, execPrefix, shellJoinArgs(copilotArgs)) | ||
| // Sandbox mode: add workspace dir and pass prompt file path directly | ||
| copilotCommand = fmt.Sprintf(`%s %s --add-dir "${GITHUB_WORKSPACE}" --prompt-file /tmp/gh-aw/aw-prompts/prompt.txt`, execPrefix, shellJoinArgs(copilotArgs)) | ||
| } else { | ||
| // Non-sandbox mode: prompt is read from a shell variable set earlier in the script | ||
| copilotCommand = fmt.Sprintf(`%s %s --prompt "$COPILOT_CLI_INSTRUCTION"`, execPrefix, shellJoinArgs(copilotArgs)) | ||
| // Non-sandbox mode: pass prompt file path directly | ||
| copilotCommand = fmt.Sprintf(`%s %s --prompt-file /tmp/gh-aw/aw-prompts/prompt.txt`, execPrefix, shellJoinArgs(copilotArgs)) | ||
| } |
There was a problem hiding this comment.
--prompt-file is emitted unconditionally, but this engine supports pinning Copilot CLI versions via engine.version. If an older pinned version doesn’t recognize --prompt-file, the workflow will fail at startup. Consider adding a version gate (similar to copilotSupportsNoAskUser) with a minimum version constant, and fall back to the previous --prompt behavior when --prompt-file isn’t supported.
| if sandboxEnabled { | ||
| // Sandbox mode: add workspace dir and inline prompt (read inside AWF container) | ||
| copilotCommand = fmt.Sprintf(`%s %s --add-dir "${GITHUB_WORKSPACE}" --prompt "$(cat /tmp/gh-aw/aw-prompts/prompt.txt)"`, execPrefix, shellJoinArgs(copilotArgs)) | ||
| // Sandbox mode: add workspace dir and pass prompt file path directly | ||
| copilotCommand = fmt.Sprintf(`%s %s --add-dir "${GITHUB_WORKSPACE}" --prompt-file /tmp/gh-aw/aw-prompts/prompt.txt`, execPrefix, shellJoinArgs(copilotArgs)) | ||
| } else { | ||
| // Non-sandbox mode: prompt is read from a shell variable set earlier in the script | ||
| copilotCommand = fmt.Sprintf(`%s %s --prompt "$COPILOT_CLI_INSTRUCTION"`, execPrefix, shellJoinArgs(copilotArgs)) | ||
| // Non-sandbox mode: pass prompt file path directly | ||
| copilotCommand = fmt.Sprintf(`%s %s --prompt-file /tmp/gh-aw/aw-prompts/prompt.txt`, execPrefix, shellJoinArgs(copilotArgs)) | ||
| } |
There was a problem hiding this comment.
The prompt path is now hard-coded in the command even though GH_AW_PROMPT is set in the step env later in this function. To avoid duplicating the prompt path in multiple places (and simplify future changes), consider using the env var in the command (and quoting it) rather than repeating /tmp/gh-aw/aw-prompts/prompt.txt.
See below for a potential fix:
// Sandbox mode: add workspace dir and use the configured prompt file path from the step env
copilotCommand = fmt.Sprintf(`%s %s --add-dir "${GITHUB_WORKSPACE}" --prompt-file "${GH_AW_PROMPT}"`, execPrefix, shellJoinArgs(copilotArgs))
} else {
// Non-sandbox mode: use the configured prompt file path from the step env
copilotCommand = fmt.Sprintf(`%s %s --prompt-file "${GH_AW_PROMPT}"`, execPrefix, shellJoinArgs(copilotArgs))
There was a problem hiding this comment.
Good suggestion! Using \$\{GH_AW_PROMPT} from the step env would centralize the prompt path and reduce duplication. The current hard-coded path works for the standard setup, but your approach is more maintainable and resilient to future path changes.
📰 BREAKING: Report filed by Smoke Copilot · ● 1M
🧪 Test Quality Sentinel ReportTest Quality Score: 90/100✅ Excellent test quality
Test Classification Details
Test Analysis✅
|
|
@copilot add support for --prompt-file in the copilot driver.
|
Agent-Logs-Url: https://github.com/github/gh-aw/sessions/21799c47-aabd-44d2-865d-c26e5aaa01e0 Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
… handling Agent-Logs-Url: https://github.com/github/gh-aw/sessions/21799c47-aabd-44d2-865d-c26e5aaa01e0 Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Implemented in eea7123 (with follow-up polish in c934094).
Not a hallucination—this is now implemented in the driver. See eea7123 (and c934094): the driver supports |
|
✅ All tools validated successfully! Agent Container Smoke Test confirms agent container is ready. |
|
📰 BREAKING: Smoke Copilot is now investigating this pull request. Sources say the story is developing... |
|
🎬 THE END — Smoke Claude MISSION: ACCOMPLISHED! The hero saves the day! ✨ |
|
✨ The prophecy is fulfilled... Smoke Codex has completed its mystical journey. The stars align. 🌟 |
|
|
--prompt-file for Copilot execution to avoid ARG_MAX failures on large prompts--prompt-file for Copilot execution and add Copilot driver fallback handling
Agent Container Tool Check
Result: 12/12 tools available ✅ Overall Status: PASS
|
|
Smoke test
Warning
|
|
🤖 Smoke Test Results — Run §24482902625
Overall: PR Author:
|
There was a problem hiding this comment.
This PR makes a solid improvement by switching from inline prompt expansion to file-based prompt passing, avoiding ARG_MAX limits. The copilot_driver.cjs changes handle the --prompt-file resolution cleanly with size-based fallback. Two minor observations: (1) consider logging inlined prompt size for observability, and (2) the buildPromptFileFallbackInstruction should document the assumption that prompt file paths are space-free. Tests and golden fixtures are well-updated.
📰 BREAKING: Report filed by Smoke Copilot · ● 1M
|
|
||
| if (i + 1 >= args.length) { | ||
| log("warning: --prompt-file provided without a path; leaving arguments unchanged"); | ||
| resolvedArgs.push(arg); |
There was a problem hiding this comment.
The resolvePromptFileArgs function reads the entire file synchronously before spawning the process. For the 100KB fallback case this is avoided, but for files slightly under the threshold the full content is still loaded into memory and passed as a CLI argument. Consider logging the inlined prompt size for observability.
| * @returns {string} | ||
| */ | ||
| function buildPromptFileFallbackInstruction(promptFile) { | ||
| return `Read the full instructions from ${promptFile} and execute them exactly as written.`; |
There was a problem hiding this comment.
The buildPromptFileFallbackInstruction returns a bare instruction string telling the agent to read from disk. However, if the prompt file path contains spaces or special characters, this instruction might not convey the path accurately. Consider quoting the path in the instruction string or documenting that prompt file paths must not contain spaces.
|
📰 VERDICT: Smoke Copilot has concluded. All systems operational. This is a developing story. 🎤 |
|
Commit pushed:
|
Smoke Test Run 24482902675 — Claude Engine
Overall: PARTIAL — 1 failure (Agentic Workflows MCP tool unavailable), 1 skip (no test PR to close).
|
There was a problem hiding this comment.
💥 Automated smoke test review - all systems nominal! This review was generated as part of the Claude engine smoke test for run §24482902675. The --prompt-file approach is a solid fix for ARG_MAX limits.
💥 [THE END] — Illustrated by Smoke Claude · ● 267.4K
| copilotCommand = fmt.Sprintf(`%s %s --prompt "$COPILOT_CLI_INSTRUCTION"`, execPrefix, shellJoinArgs(copilotArgs)) | ||
| // Non-sandbox mode: pass prompt file path directly | ||
| copilotCommand = fmt.Sprintf(`%s %s --prompt-file /tmp/gh-aw/aw-prompts/prompt.txt`, execPrefix, shellJoinArgs(copilotArgs)) | ||
| } |
There was a problem hiding this comment.
🔍 Smoke Test Observation: The --prompt-file path is hard-coded to /tmp/gh-aw/aw-prompts/prompt.txt in both sandbox and non-sandbox modes. This looks consistent with the existing convention, but consider whether a constant or an env var reference (\$\{GH_AW_PROMPT}) would make future path changes easier to manage.
|
|
||
| if (i + 1 >= args.length) { | ||
| log("warning: --prompt-file provided without a path; leaving arguments unchanged"); | ||
| resolvedArgs.push(arg); |
There was a problem hiding this comment.
🔍 Smoke Test Observation: The resolvePromptFileArgs function correctly handles the edge cases (missing path, oversized file, unreadable file). The PROMPT_FILE_INLINE_THRESHOLD_BYTES = 100 * 1024 threshold is well-chosen for avoiding ARG_MAX issues. Good defensive coding here!
Large imported/inlined prompts were expanded into a single argv entry via
--prompt "$(cat ...)", which can exceed LinuxARG_MAXand fail before the agent process starts. This updates Copilot command generation to keep prompt content on disk and pass only the file path.Command construction change (AWF + non-AWF)
--prompt "$(cat /tmp/gh-aw/aw-prompts/prompt.txt)"--prompt "$COPILOT_CLI_INSTRUCTION"--prompt-file /tmp/gh-aw/aw-prompts/prompt.txtCopilot driver
--prompt-filesupportactions/setup/js/copilot_driver.cjsto resolve--prompt-filebefore spawning Copilot:-p(existing small-prompt behavior).-pinstruction telling the agent to read and execute the prompt file from disk.actions/setup/js/copilot_driver.test.cjsfor:Regression coverage
--prompt-fileusage and ensure prompt text is no longer loaded into a shell variable.Changeset
--prompt-filefor Copilot execution so large prompts do not exceed LinuxARG_MAXand fail before agent startup.Warning
The following domains were blocked by the firewall during workflow execution:
ab.chatgpt.comchatgpt.comTo allow these domains, add them to the
network.allowedlist in your workflow frontmatter:See Network Configuration for more information.
✨ PR Review Safe Output Test - Run 24482902675