Extract agent timeout message to markdown template#22088
Conversation
Move the hardcoded timeout message from buildTimeoutContext() in
handle_agent_failure.cjs into actions/setup/md/agent_timeout.md.
The new template uses {current_minutes} and {suggested_minutes}
placeholders rendered via renderTemplate(), following the same
pattern used by buildInferenceAccessErrorContext() and
buildLockdownCheckFailedContext().
The setup.sh script already copies all md/*.md files to
${RUNNER_TEMP}/gh-aw/prompts/ at runtime, so the file is
automatically available to the conclusion job.
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Agent-Logs-Url: https://github.com/github/gh-aw/sessions/2718c9d9-d8d3-4899-8818-0818d6bde90a
There was a problem hiding this comment.
Pull request overview
This PR standardizes the agent-timeout failure messaging by moving the timeout text from inline string concatenation into a reusable markdown template, aligning it with other failure contexts that use templates.
Changes:
- Added a new markdown template for agent timeout messaging with placeholder substitution.
- Updated
buildTimeoutContext()to load and render the timeout template from the runtime prompts directory.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
actions/setup/md/agent_timeout.md |
Adds a new markdown template for the agent timeout failure context with {current_minutes} / {suggested_minutes} placeholders. |
actions/setup/js/handle_agent_failure.cjs |
Switches buildTimeoutContext() to read the new template and render it via renderTemplate. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| const template = fs.readFileSync(templatePath, "utf8"); | ||
| return "\n" + renderTemplate(template, { current_minutes: currentMinutes, suggested_minutes: suggestedMinutes }); | ||
| } | ||
|
|
There was a problem hiding this comment.
buildTimeoutContext() behavior changed to load and render agent_timeout.md, but actions/setup/js/handle_agent_failure.test.cjs currently doesn’t cover this path (it covers other context builders). To prevent regressions (missing template, placeholder mismatch, wrong path), add a unit test that stubs fs.readFileSync for agent_timeout.md and asserts the rendered output includes the expected current_minutes / suggested_minutes values. Since buildTimeoutContext isn’t exported today, consider exporting it (non-breaking) similar to the other context builders so it can be tested directly.
| module.exports.buildTimeoutContext = buildTimeoutContext; |
|
@copilot review comments |
Export buildTimeoutContext from handle_agent_failure.cjs so it can be
tested directly, following the same pattern as other exported context
builders.
Add unit tests that stub fs.readFileSync for agent_timeout.md and
assert correct rendering of {current_minutes} and {suggested_minutes}
placeholders, including the default-minutes fallback and the +10
suggestion logic.
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Agent-Logs-Url: https://github.com/github/gh-aw/sessions/991ce53a-a7f5-4337-845b-de6f685d5d0f
Addressed in ad31df1: exported |
|
Hey The PR is clean, well-described, and comes with solid test coverage (four scenarios: not-timed-out guard, basic formatted output, empty Note 🔒 Integrity filtering filtered 1 itemIntegrity filtering activated and filtered the following item during workflow execution.
|
The timeout error text in
buildTimeoutContext()was hardcoded as JavaScript string concatenation, inconsistent with how other error contexts (inference access, app token minting, lockdown) are handled via markdown templates inactions/setup/md/.Changes
actions/setup/md/agent_timeout.md— new template file with{current_minutes}and{suggested_minutes}placeholders:buildTimeoutContext()inhandle_agent_failure.cjs— replaced hardcoded string building with afs.readFileSync+renderTemplatecall, matching the pattern ofbuildInferenceAccessErrorContextandbuildLockdownCheckFailedContext.setup.shalready copies allactions/setup/md/*.mdfiles to${RUNNER_TEMP}/gh-aw/prompts/at runtime, so no setup changes are needed.