Skip to content

feat: compute models.json in activation via on-the-fly alias merge#34681

Closed
Copilot wants to merge 3 commits into
mainfrom
copilot/add-compute-models-json-step
Closed

feat: compute models.json in activation via on-the-fly alias merge#34681
Copilot wants to merge 3 commits into
mainfrom
copilot/add-compute-models-json-step

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 25, 2026

Activation jobs were inlining model alias data (or omitting it entirely), causing code bloat and making model resolution unavailable to runtime scripts. This PR introduces a Compute models activation step that merges pre-computed builtin aliases with per-workflow user overrides at runtime, producing /tmp/gh-aw/models.json in the activation artifact.

Approach

  • Builtin aliases live in actions/setup/js/models.json (mirrored from data/model_aliases.json), copied by setup.sh to RUNNER_TEMP — never inlined in compiled YAML
  • User overrides (frontmatter models: + imported workflow aliases) are emitted as GH_AW_INFO_MODEL_ALIASES — a compact JSON delta omitted entirely when no overrides are defined
  • compute_models.cjs merges the two layers (user wins) → writes /tmp/gh-aw/models.json → logs a collapsible alias table to the step summary
  • /tmp/gh-aw/models.json is added to the activation artifact upload

Changes

JS (actions/setup/js/)

  • models.json — new pre-computed builtin alias file (auto-copied by setup.sh *.json glob)
  • compute_models.cjs — merge helper: loadBuiltinAliases() + loadUserAliases()mergeAliases() → write + summary
  • compute_models.test.cjs — 22 unit tests
  • constants.cjs — adds MODELS_JSON_PATH

Go (pkg/workflow/)

  • model_aliases.goMergeUserModelAliases(): like MergeImportedModelAliases but without the builtins layer
  • compiler_types.goUserModelAliases field on WorkflowData (user-level delta only)
  • workflow_builder.go — populate UserModelAliases alongside ModelMappings
  • compiler_yaml.go — emit GH_AW_INFO_MODEL_ALIASES in generate_aw_info env block (only when non-empty)
  • compiler_activation_job_builder.gogenerateComputeModelsStep() inserted after generate_aw_info; /tmp/gh-aw/models.json added to artifact paths

Result

For a workflow with no custom models, zero model alias data appears in the compiled YAML. For a workflow with overrides, only the delta is inlined:

- name: Generate agentic run info
  id: generate_aw_info
  env:
    GH_AW_INFO_MODEL_ALIASES: '{"my-alias":["openai/my-model-v1"]}'  # compact delta only
    ...
- name: Compute models
  id: compute_models
  uses: actions/github-script@...
  with:
    script: |
      ...
      const { main } = require('.../compute_models.cjs');
      await main();

Copilot AI and others added 2 commits May 25, 2026 15:37
- Add actions/setup/js/models.json (pre-computed builtin aliases, copy of data/model_aliases.json)
- Add MODELS_JSON_PATH constant to actions/setup/js/constants.cjs
- Add actions/setup/js/compute_models.cjs: merges builtin + user aliases, writes /tmp/gh-aw/models.json, logs to step summary
- Add actions/setup/js/compute_models.test.cjs: 22 unit tests (all passing)
- Add MergeUserModelAliases() helper in model_aliases.go (user-level delta without builtins)
- Add UserModelAliases field to WorkflowData (compact delta for GH_AW_INFO_MODEL_ALIASES)
- Populate UserModelAliases in workflow_builder.go
- Emit GH_AW_INFO_MODEL_ALIASES env var in compiler_yaml.go generateCreateAwInfo (only when non-empty)
- Add generateComputeModelsStep() in compiler_activation_job_builder.go (new "Compute models" step after generate_aw_info)
- Add /tmp/gh-aw/models.json to activation artifact upload paths
- Update golden test fixtures

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
…P note)

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title feat: add compute_models activation step for on-fly model alias merging feat: compute models.json in activation via on-the-fly alias merge May 25, 2026
Copilot AI requested a review from pelikhan May 25, 2026 15:42
@pelikhan
Copy link
Copy Markdown
Collaborator

@copilot use computed models.json when configuring awf

…time

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

Copilot AI commented May 25, 2026

@copilot use computed models.json when configuring awf

Done in the latest commit. BuildAWFConfigJSON no longer inlines ModelMappings in the static config — instead, BuildAWFCommand appends a Python script to the configFileSetup block that reads /tmp/gh-aw/models.json (downloaded from the activation artifact) and patches apiProxy.models into awf-config.json at runtime, before AWF is invoked. This keeps compiled YAML lean while ensuring AWF always gets the full merged alias map.

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.

2 participants