Skip to content

Add support for importing safe-outputs from shared agentic workflows#4761

Merged
pelikhan merged 8 commits intomainfrom
copilot/add-support-importing-safe-outputs
Nov 25, 2025
Merged

Add support for importing safe-outputs from shared agentic workflows#4761
pelikhan merged 8 commits intomainfrom
copilot/add-support-importing-safe-outputs

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Nov 25, 2025

  • Understand the existing codebase structure
  • Create MergeSafeOutputs function in imports.go to merge safe-output configurations from imports
  • Add conflict detection for overlapping safe-output types (create-issue, create-discussion, etc.)
  • Integrate merge function into compiler.go
  • Add test cases for safe-outputs import functionality
  • Add test cases for conflict detection
  • Run build and linting to validate changes
  • Run code review and address feedback
  • Run CodeQL security checks
  • Run agent-finish to verify all workflows compile
  • Extract safe-output type keys from embedded JSON schema instead of hardcoding
  • Add support for importing safe-output meta fields (allowed-domains, staged, env, github-token, max-patch-size, runs-on)

Summary

This PR adds support for importing safe-outputs (like create-issue, add-comment, create-discussion, etc.) and meta fields from shared agentic workflows using the imports: field.

Changes

  • pkg/parser/schema.go: Added GetSafeOutputTypeKeys() function to extract safe output type keys from the embedded main workflow schema, filtering out meta-configuration fields
  • pkg/workflow/imports.go:
    • Updated to use parser.GetSafeOutputTypeKeys() instead of a hardcoded list, with caching for performance
    • Added support for importing meta fields: allowed-domains, staged, env, github-token, max-patch-size, runs-on
    • Updated merge logic to include configs with only meta fields (not just safe output types)
  • pkg/workflow/compiler.go: Integrated merge into workflow parsing pipeline
  • pkg/workflow/safe_outputs_import_test.go: Comprehensive tests for import and conflict scenarios, including meta field tests
  • pkg/parser/schema_test.go: Added test for GetSafeOutputTypeKeys()

Usage

Shared workflow (shared-config.md):

---
safe-outputs:
  create-issue:
    title-prefix: "[shared] "
    labels: [imported]
  allowed-domains:
    - "example.com"
  staged: true
  github-token: "${{ secrets.CUSTOM_TOKEN }}"
  max-patch-size: 2048
  runs-on: "ubuntu-22.04"
---

Main workflow:

---
on: issues
imports:
  - ./shared-config.md
---

Conflict handling

If the same safe-output type is defined in both main and imported workflow:

safe-outputs conflict: 'create-issue' is defined in both the main workflow and an imported workflow

Note: Main workflow values take precedence over imported values for meta fields.

Original prompt

Add support for importing safe-outputs from shared agentic workflows. If a conflict is found while importing, fail the compilation.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits November 25, 2025 17:27
…flows

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Add support for importing safe-outputs from shared workflows Add support for importing safe-outputs from shared agentic workflows Nov 25, 2025
Copilot AI requested a review from pelikhan November 25, 2025 17:36
Comment thread pkg/workflow/imports.go Outdated

// safeOutputTypeKeys lists all the safe output type keys that are used in frontmatter
// These are the keys that define actual safe output operations (not meta configuration like app, jobs, staged, etc.)
var safeOutputTypeKeys = []string{
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@copilot can you mine these keys from of an the embedded main JSON schema?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added GetSafeOutputTypeKeys() in pkg/parser/schema.go that parses the embedded main_workflow_schema.json and extracts safe-output type keys dynamically. Meta-configuration fields (allowed-domains, staged, env, github-token, app, max-patch-size, jobs, runs-on) are filtered out. Results are cached using sync.Once for performance. Commit: 1c94c28

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI requested a review from pelikhan November 25, 2025 17:58
@pelikhan pelikhan marked this pull request as ready for review November 25, 2025 17:59
Copilot AI review requested due to automatic review settings November 25, 2025 17:59
@pelikhan
Copy link
Copy Markdown
Collaborator

@copilot also allow import safe output meta fields

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds support for importing safe-output configurations (such as create-issue, add-comment, create-discussion) from shared agentic workflows using the imports: field. The implementation extracts safe output type keys dynamically from the embedded JSON schema rather than hardcoding them, and includes conflict detection to prevent the same safe-output type from being defined in multiple locations.

Key changes:

  • Dynamic schema-based safe output type extraction for maintainability
  • Conflict detection between main and imported safe-output configurations
  • Comprehensive test coverage for import scenarios and edge cases

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
pkg/parser/schema.go Adds GetSafeOutputTypeKeys() function to extract safe output type keys from the embedded main workflow schema, filtering out meta-configuration fields like allowed-domains, staged, and env
pkg/parser/schema_test.go Adds comprehensive test for GetSafeOutputTypeKeys() verifying correct extraction of safe output types and exclusion of meta fields
pkg/workflow/imports.go Implements MergeSafeOutputs() with conflict detection, uses schema-extracted keys with caching, includes hasSafeOutputType() and mergeSafeOutputConfig() helper functions
pkg/workflow/compiler.go Integrates safe-outputs merging into the workflow parsing pipeline after processing other imports
pkg/workflow/safe_outputs_import_test.go Provides comprehensive integration and unit tests covering import scenarios, conflict detection (main vs import, import vs import), and multi-workflow imports
docs/src/content/docs/labs.mdx Adds entry for "Daily Fact About gh-aw" workflow (appears unrelated to the PR's core purpose)

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

You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.

Comment thread docs/src/content/docs/labs.mdx Outdated
@pelikhan
Copy link
Copy Markdown
Collaborator

@copilot the safe-outputs content in app-config.md should also be importable (the app field)

…orkflows

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Nov 25, 2025

@copilot also allow import safe output meta fields

Added support for importing safe-output meta fields: allowed-domains, staged, env, github-token, max-patch-size, and runs-on. Main workflow values take precedence over imported values. Commit: d5580e8

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Nov 25, 2025

@copilot the safe-outputs content in app-config.md should also be importable (the app field)

The app field in safe-outputs is already importable and working. The implementation was added in earlier commits via mergeAppFromIncludedConfigs in safe_outputs_app.go. The tests in pkg/workflow/safe_outputs_app_import_test.go verify this functionality - TestSafeOutputsAppImport, TestSafeOutputsAppImportOverride, and TestSafeOutputsAppImportStepGeneration all pass. You can import shared/app-config.md into any workflow using the standard imports syntax.

@pelikhan pelikhan added the smoke label Nov 25, 2025
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Nov 25, 2025

✅ Agentic Changeset Generator completed successfully.

@pelikhan pelikhan merged commit 7c246d0 into main Nov 25, 2025
15 checks passed
@pelikhan pelikhan deleted the copilot/add-support-importing-safe-outputs branch November 25, 2025 21:34
github-actions Bot added a commit that referenced this pull request Nov 26, 2025
Updates documentation for three major features merged in the last 24 hours:

1. CLI --ref flag (#4776)
   - Add --ref flag to gh aw status command
   - Add --ref flag to gh aw logs command
   - Shows latest run status when filtering by branch/tag

2. Import safe-outputs from shared workflows (#4761, #4782)
   - Document safe-outputs importing capability
   - Document safe output jobs import support
   - Explain conflict detection and meta field precedence

3. Custom job outputs support (#4778)
   - Document job output definition syntax
   - Show usage in agent prompts with needs context
   - Note string value requirement

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants