Skip to content

Fix docs: custom safe-output jobs run once per run, not once per tool call - #50635

Merged
pelikhan merged 2 commits into
mainfrom
copilot/update-custom-jobs-documentation
Aug 5, 2026
Merged

pelikhan merged 2 commits into
mainfrom
copilot/update-custom-jobs-documentation

Conversation

Copilot AI commented Aug 5, 2026 •

Copy link
Copy Markdown
Contributor

docs/reference/custom-safe-outputs.md incorrectly claimed safe-outputs.jobs custom jobs run once per agent tool call. The compiler emits a single job per workflow run (no strategy: matrix), so all calls are collected into .items[]. The wrong model leads to silent data loss: implementing against it, you read .items[0] and drop every call after the first — with no error.

Changes

  • Corrected invocation model: jobs run "as a single separate GitHub Actions job per workflow run, processing all of that tool's calls together"; scripts run in-process, once per tool call.
  • Fixed comparison table: Slower (new job per call) → Slower (one job per run), and added an Invocation row contrasting scripts (per call) vs jobs (per run).
  • Added [!IMPORTANT] note in the jobs section: the job must iterate .items[], and reading .items[0] silently drops later calls.
  • Documented the secrets edge case: scripts can't read repository secrets, so per-item handling that needs a token must be a job — and therefore must loop.

The doc example already uses the correct once-per-run pattern:

cat "$GH_AW_AGENT_OUTPUT" | jq -c '.items[] | select(.type == "my_job")'

Docs-only change; no code or workflows touched.

@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Thanks for working on this documentation fix! 📚 The issue you're addressing is well-scoped and directly improves our docs' accuracy — catching and correcting the silent data loss footgun around custom job execution is valuable.

Current Status

  • ✅ Draft mode — good practice while work is in progress
  • ✅ Well-documented problem statement with specific line references and reproduction steps
  • ⚠️ No changes committed yet — the PR currently has 0 lines changed
  • ⚠️ Not ready for review — wait until you've implemented the doc fixes before requesting reviewers

Next Steps
Once you've made the changes to docs/src/content/docs/reference/custom-safe-outputs.md, this PR will be ready:

  1. Fix the three locations mentioned in the issue (clarify jobs run once per workflow run, not per call; correct the table cell and add invocation row; add explicit note about iterating .items[] and the .items[0] footgun)
  2. Add the optional note about per-item handling with secrets requiring a job with a loop
  3. When ready, mark the PR as ready for review (convert from draft)

Keep the PR description updated as you make progress, and you're all set! 🚀

Generated by ✅ Contribution Check · auto · 46.3 AIC · ⌖ 4.76 AIC · ⊞ 8.8K · ◷

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Update documentation for safe-outputs.jobs custom jobs Fix docs: custom safe-output jobs run once per run, not once per tool call Aug 5, 2026
Copilot AI requested a review from pelikhan August 5, 2026 17:26
@pelikhan
pelikhan marked this pull request as ready for review August 5, 2026 17:35
Copilot AI balanced review requested due to automatic review settings August 5, 2026 17:35
@pelikhan
pelikhan merged commit 96a6e0c into main Aug 5, 2026
@pelikhan
pelikhan deleted the copilot/update-custom-jobs-documentation branch August 5, 2026 17:35

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Corrects custom safe-output job invocation documentation and clarifies job/script behavior.

Changes:

  • Documents once-per-run custom jobs and .items[] iteration.
  • Updates the scripts-versus-jobs comparison and secret-handling guidance.
Show a summary per file
File Description
docs/src/content/docs/reference/custom-safe-outputs.md Clarifies safe-output invocation and processing models.

Review details

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 1/1 changed files
  • Comments generated: 2
  • Review effort level: Balanced

The `inputs:` schema serves as both the MCP tool definition visible to the agent and validation for the output fields written to `GH_AW_AGENT_OUTPUT`.

> [!IMPORTANT]
> A custom job runs **once per workflow run**, not once per tool call. If the agent calls the tool multiple times, every call is collected into the `.items[]` array of the single `GH_AW_AGENT_OUTPUT` file. Your job must iterate over `.items[]` (for example with `jq -c '.items[] | select(.type == "my_job")'`) to process all calls. Reading only `.items[0]` silently drops every call after the first — the run still succeeds, so the data loss is easy to miss.
> [!IMPORTANT]
> A custom job runs **once per workflow run**, not once per tool call. If the agent calls the tool multiple times, every call is collected into the `.items[]` array of the single `GH_AW_AGENT_OUTPUT` file. Your job must iterate over `.items[]` (for example with `jq -c '.items[] | select(.type == "my_job")'`) to process all calls. Reading only `.items[0]` silently drops every call after the first — the run still succeeds, so the data loss is easy to miss.
>
> Because inline [scripts](#inline-script-handlers-safe-outputsscripts) cannot access repository secrets, any per-item handler that needs a secret (for example to call an external API with a token) must be a job — and therefore must loop over `.items[]` itself.
@github-actions

github-actions Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

🎉 This pull request is included in a new release.

Release: v0.85.4

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.

Docs: safe-outputs.jobs custom jobs run once per workflow run, not once per tool call

3 participants