Skip to content

docs: hint at jq file injection for safe-output body fields - #48909

Merged
pelikhan merged 1 commit into
mainfrom
copilot/update-safe-outputs-cli-proxy-instruction
Jul 29, 2026
Merged

docs: hint at jq file injection for safe-output body fields#48909
pelikhan merged 1 commit into
mainfrom
copilot/update-safe-outputs-cli-proxy-instruction

Conversation

Copilot AI commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Agents editing large bodies (issues, discussions, PRs) must currently re-embed the full content inline in the safe-output payload, increasing token cost. A jq -Rs pipe pattern avoids this by reading from a local file without @filename expansion (which safeoutputs rejects).

Changes

  • mcp_cli_tools_prompt.md: Adds a jq -Rs example alongside the existing stdin-pipe pattern, with a note explaining why raw cat file | safeoutputs ... is rejected (body field not populated → validation error):

    jq -Rs --arg discussion_number "$DISCUSSION_NUMBER" \
      '{discussion_number: ($discussion_number|tonumber), body: .}' \
      discussion-body.md \
      | safeoutputs update_discussion .
  • safe_outputs_prompt.md: Extends the @filename-not-supported note to point agents toward jq -Rs as the correct alternative.

…tion

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title hint: add jq file injection example to safe outputs CLI proxy instruction docs: hint at jq file injection for safe-output body fields Jul 29, 2026
Copilot AI requested a review from pelikhan July 29, 2026 14:31
@pelikhan
pelikhan marked this pull request as ready for review July 29, 2026 14:33
Copilot AI review requested due to automatic review settings July 29, 2026 14:33
@pelikhan
pelikhan merged commit c470a5f into main Jul 29, 2026
@pelikhan
pelikhan deleted the copilot/update-safe-outputs-cli-proxy-instruction branch July 29, 2026 14:33

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

Adds file-based jq -Rs guidance for constructing safe-output body payloads.

Changes:

  • Documents file-to-JSON body injection.
  • Clarifies unsupported @filename expansion.
  • Adds a patch changeset.
Show a summary per file
File Description
actions/setup/md/safe_outputs_prompt.md Adds concise file-injection guidance.
actions/setup/md/mcp_cli_tools_prompt.md Adds a detailed jq -Rs example.
.changeset/hint-jq-file-injection-safe-outputs-prompt.md Records the documentation change.

Review details

Tip

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

  • Files reviewed: 3/3 changed files
  • Comments generated: 3
  • Review effort level: Medium

Comment on lines +18 to +19
jq -Rs --arg discussion_number "$DISCUSSION_NUMBER" \
'{discussion_number: ($discussion_number|tonumber), body: .}' \
temporary_id: optional cross-reference field for future resources created by safe outputs. Canonical form: '#aw_' followed by 3–12 alphanumeric or underscore characters — e.g., '#aw_abc1', '#aw_pr_fix'. Pattern: /^#?aw_[A-Za-z0-9_]{3,12}$/i (the '#' prefix is optional; bare 'aw_abc1' is accepted and normalised to '#aw_abc1' automatically). Use this form for all field values (temporary_id, item_number, issue_number, parent, etc.). In body/markdown text, '#aw_abc1' references are replaced with the real issue/PR number after creation. Omit entirely when not needed.

**Note**: safeoutputs tools do NOT support `@filename` file name expansion. Always provide content inline — do not use `@filename` references in tool arguments.
**Note**: safeoutputs tools do NOT support `@filename` file name expansion. Always provide content inline — do not use `@filename` references in tool arguments. To inject an entire file as the `body` field, use `jq -Rs` to read it as a JSON string and pipe the resulting payload: `jq -Rs '{body: .}' file.md | safeoutputs update_discussion .`
discussion-body.md \
| safeoutputs update_discussion .
```
`jq -Rs` reads the file as a raw string (`-R`) and slurps it into a single JSON string value (`-s`), so `body` is always a valid JSON field. Piping `cat file | safeoutputs ...` does not populate `body` and will be rejected.
@github-actions

Copy link
Copy Markdown
Contributor

🎉 This pull request is included in a new release.

Release: v0.84.0

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.

3 participants