Skip to content

Add declarative custom-engine frontmatter and migrate Crush/OpenCode to shared behavior definitions#44465

Open
pelikhan with Copilot wants to merge 44 commits into
mainfrom
copilot/define-agentic-engine-syntax
Open

Add declarative custom-engine frontmatter and migrate Crush/OpenCode to shared behavior definitions#44465
pelikhan with Copilot wants to merge 44 commits into
mainfrom
copilot/define-agentic-engine-syntax

Conversation

Copilot AI commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

This introduces a richer engine-definition frontmatter shape for shared/custom agentic engines and uses it to move Crush and OpenCode off bespoke Go implementations onto a common declarative runtime path. The new syntax is expressive enough for CLI-style engines that need install, config, execution, MCP, capability, and auth wiring, including Auggie-like cases.

  • New engine-definition surface

    • Adds engine.experimental, engine.auth, and engine.behaviors to the named engine definition form.
    • behaviors captures the runtime contract instead of hard-coding it in Go:
      • capabilities
      • manifest files/path prefixes
      • installation metadata
      • config file generation
      • execution command/args/env
      • MCP config target
    • auth provides explicit secret bindings for engines that need engine-specific credentials forwarded into the runtime.
  • Shared behavior-defined runtime

    • Adds a generic BehaviorDefinedEngine that materializes a CodingAgentEngine from frontmatter.
    • Reuses the existing universal provider/model routing where applicable, but also supports engine-specific secret/env bindings for nonstandard CLIs.
    • Registers imported named engine definitions during compilation so shared workflows can define engines declaratively instead of requiring Go registration.
  • Crush/OpenCode refactor

    • Replaces the bespoke Crush/OpenCode runtime logic with thin wrappers over builtin engine definitions.
    • Moves engine-specific behavior into:
      • pkg/workflow/data/engines/crush.md
      • pkg/workflow/data/engines/opencode.md
    • Keeps their existing runtime identity while making their install/config/execute behavior data-driven.
  • Schema and docs

    • Extends the workflow schema and frontmatter reference docs to describe the new engine-definition fields.
    • Documents the custom-engine shape with behavior blocks and auth bindings so new engines can be added without copy-pasting a dedicated Go implementation.
  • Coverage

    • Adds/updates tests for:
      • schema shape
      • builtin engine definitions
      • imported behavior-defined engines
      • Crush/OpenCode parity through the shared path
    • Includes an imported Auggie-style engine example to exercise explicit auth binding and declarative execution.

Example of the new shared engine definition shape:

engine:
  id: auggie
  display-name: Auggie
  experimental: true
  auth:
    - role: session
      secret: AUGMENT_SESSION_AUTH
  behaviors:
    supported-env-var-keys:
      - AUGMENT_SESSION_AUTH
    installation:
      package-manager: npm
      package-name: "@augmentcode/auggie"
      version: "1.0.0"
      step-name: Install Auggie
      binary-name: auggie
      include-node-setup: true
    config-file:
      path: .auggie.json
      step-name: Write Auggie Config
      content: '{"sandbox":"workspace-write"}'
      merge-strategy: json-merge
    execution:
      command-name: auggie
      args: [run]
      step-name: Execute Auggie CLI
      model-env-var: AUGGIE_MODEL
      mcp-config-env-var: AUGGIE_MCP_CONFIG
      write-timestamp: true

Generated by 👨‍🍳 PR Sous Chef · 10.4 AIC · ⌖ 5.15 AIC · ⊞ 7.1K ·
Comment /souschef to run again


Generated by 👨‍🍳 PR Sous Chef · 16.6 AIC · ⌖ 7.21 AIC · ⊞ 4.7K ·
Comment /souschef to run again


Generated by 👨‍🍳 PR Sous Chef · 8.9 AIC · ⌖ 5.99 AIC · ⊞ 4.7K ·
Comment /souschef to run again


Generated by 👨‍🍳 PR Sous Chef · 6.57 AIC · ⌖ 6.74 AIC · ⊞ 7.1K ·
Comment /souschef to run again


Generated by 👨‍🍳 PR Sous Chef · 4.36 AIC · ⌖ 7.98 AIC · ⊞ 4.7K ·
Comment /souschef to run again


Generated by 👨‍🍳 PR Sous Chef · 7.94 AIC · ⌖ 6.73 AIC · ⊞ 7.1K ·
Comment /souschef to run again


Generated by 👨‍🍳 PR Sous Chef · 9.71 AIC · ⌖ 6.72 AIC · ⊞ 7.1K ·
Comment /souschef to run again


Generated by 👨‍🍳 PR Sous Chef · 12.5 AIC · ⌖ 6.14 AIC · ⊞ 7.1K ·
Comment /souschef to run again


Generated by 👨‍🍳 PR Sous Chef · 4.34 AIC · ⌖ 5.93 AIC · ⊞ 7.1K ·
Comment /souschef to run again


Generated by 👨‍🍳 PR Sous Chef · 11.3 AIC · ⌖ 6.23 AIC · ⊞ 7.1K ·
Comment /souschef to run again


Generated by 👨‍🍳 PR Sous Chef · 10.4 AIC · ⌖ 4.23 AIC · ⊞ 7.1K ·
Comment /souschef to run again

Copilot AI and others added 3 commits July 9, 2026 03:49
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
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 Add declarative frontmatter syntax for custom agentic engines Add declarative custom-engine frontmatter and migrate Crush/OpenCode to shared behavior definitions Jul 9, 2026
Copilot AI requested a review from pelikhan July 9, 2026 04:18
@pelikhan

pelikhan commented Jul 9, 2026

Copy link
Copy Markdown
Collaborator

@copilot remove crush/opencode from Go code and only keep them as shared agentic workflow files.

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

pelikhan commented Jul 9, 2026

Copy link
Copy Markdown
Collaborator

@copilot create a new instruction file to help with configuring new agentic engines

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

Copilot AI commented Jul 9, 2026

Copy link
Copy Markdown
Contributor Author

@copilot remove crush/opencode from Go code and only keep them as shared agentic workflow files.

Addressed in 5537932.

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

Copilot AI commented Jul 9, 2026

Copy link
Copy Markdown
Contributor Author

@copilot create a new instruction file to help with configuring new agentic engines

Addressed in ab02806.

@pelikhan

pelikhan commented Jul 9, 2026

Copy link
Copy Markdown
Collaborator

@copilot merge main and recompile
Run pr-finisher skill

Copilot AI and others added 3 commits July 9, 2026 05:20
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
…c-engine-syntax

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

Copilot AI commented Jul 9, 2026

Copy link
Copy Markdown
Contributor Author

@copilot merge main and recompile
Run pr-finisher skill

Addressed in 1610bec.

@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot please run the pr-finisher skill, address any unresolved review feedback, and rerun checks once the branch is up to date.

Generated by 👨‍🍳 PR Sous Chef · 6.4 AIC · ⌖ 6.49 AIC · ⊞ 7.5K ·
Comment /souschef to run again

@gh-aw-bot

Copy link
Copy Markdown
Collaborator

pr-sous-chef
@copilot please run the pr-finisher skill, address unresolved review comments, and rerun checks once the branch is up to date.

Generated by 👨‍🍳 PR Sous Chef · 6.4 AIC · ⌖ 6.49 AIC · ⊞ 7.5K ·
Comment /souschef to run again

Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>
@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot please run the pr-finisher skill, address unresolved review comments if any, and rerun checks once the branch is up to date.

Generated by 👨‍🍳 PR Sous Chef · 7.7 AIC · ⌖ 4.78 AIC · ⊞ 7.5K ·
Comment /souschef to run again

Copilot AI and others added 2 commits July 10, 2026 19:34
…de.jsonc config

When AWF credential isolation unsets OPENAI_API_KEY from the agent container
environment, OpenCode v1.2.14 cannot initialise the 'openai' provider and falls
back to the built-in 'opencode.ai' provider (model: big-pickle).  That provider
bypasses the AWF api-proxy entirely, so token_usage.jsonl stays empty and
check_token_telemetry fails.

Fix: add providers.openai.apiKey = "awf-copilot-proxy" to the opencode.jsonc
config written before the agent runs.  The AWF api-proxy accepts any non-empty
placeholder key (credential isolation is active; it uses its own configured
COPILOT_GITHUB_TOKEN for upstream auth).  With the key present in the config
file, OpenCode initialises the openai provider, routes LLM calls through
OPENAI_BASE_URL (the api-proxy), and token telemetry is captured correctly.

Also adds test assertions to verify the providers block and placeholder key
appear in the generated config step.

Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>
…ILL.md

Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>

Copilot AI commented Jul 10, 2026

Copy link
Copy Markdown
Contributor Author

@copilot please run the pr-finisher skill, address any unresolved review feedback, and rerun checks once the branch is up to date.

...

Fixed in 671bfeb.

Root cause: AWF credential isolation unsets OPENAI_API_KEY from /proc/1/environ before OpenCode starts. Without the env var, OpenCode v1.2.14 cannot initialise the openai provider and silently falls back to the built-in opencode.ai provider (big-pickle model). That provider bypasses the AWF api-proxy entirely, so token_usage.jsonl stays empty and check_token_telemetry fails.

Fix: Added providers.openai.apiKey: "awf-copilot-proxy" to the opencode.jsonc config written at the start of each run. The AWF api-proxy accepts any non-empty placeholder key (it uses its own configured COPILOT_GITHUB_TOKEN via credential isolation for upstream auth), so OpenCode's openai provider initialises successfully, routes through OPENAI_BASE_URL (the api-proxy), and token usage is tracked.

Also restored an accidentally-removed configure-agentic-engine.md reference in SKILL.md (93b6f60).

A maintainer re-trigger of /smoke-opencode is needed to confirm CI green.

…F Copilot proxy

OpenCode's built-in `opencode` provider routes all LLM calls to opencode.ai
directly, bypassing the AWF api-proxy entirely. This means token_usage.jsonl
is never written and the check_token_telemetry job fails.

Fix: write the following fields into opencode.jsonc during the config step:
- `disabled_providers: ["opencode"]` — prevents the opencode.ai smart router
  from intercepting model requests
- `provider.openai.options.baseURL: http://host.docker.internal:10002` —
  explicitly configures the openai provider to send requests through the AWF
  Copilot LLM gateway (same URL already set in OPENAI_BASE_URL env var)
- `provider.openai.models.gpt-5: {}` — registers gpt-5 under the openai
  provider so OPENCODE_MODEL=openai/gpt-5 resolves without hitting models.dev

With the opencode provider disabled, OPENCODE_MODEL=openai/gpt-5 routes to
OpenCode's built-in openai provider (backed by @ai-sdk/openai). Since that
provider is activated via config (not built-in autoload), OpenCode uses
sdk.languageModel() (Chat Completions format) rather than sdk.responses()
(Responses API), which the AWF Copilot proxy at port 10002 handles correctly.
All LLM calls go through the proxy → OPENAI_API_KEY (GitHub Copilot token)
used for auth → token_usage.jsonl written → check_token_telemetry passes.

Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>

Copilot AI commented Jul 10, 2026

Copy link
Copy Markdown
Contributor Author

@copilot please run the pr-finisher skill, address any unresolved review feedback, and rerun checks once the branch is up to date.

...

Fixed in commit Fix OpenCode token telemetry: disable opencode provider, route via AWF Copilot proxy.

Root cause: OpenCode's built-in opencode provider routes all LLM calls to opencode.ai directly (acting as a smart model router), bypassing the AWF api-proxy entirely. When OPENCODE_MODEL=openai/gpt-5 was set, opencode.ai mapped it to opencode/big-pickle and handled inference — so token_usage.jsonl was never written by the AWF proxy.

Fix (pkg/workflow/data/engines/opencode.md): Added three fields to the opencode.jsonc config written during the config step:

  • "disabled_providers": ["opencode"] — prevents the opencode.ai model router from intercepting requests
  • "provider": {"openai": {"options": {"baseURL": "http://host.docker.internal:10002"}}} — activates the openai provider pointing at the AWF Copilot LLM gateway
  • "models": {"gpt-5": {}} — registers gpt-5 explicitly so OPENCODE_MODEL=openai/gpt-5 resolves without needing the models.dev catalog

With the opencode provider disabled, the openai provider (backed by @ai-sdk/openai) handles the request using Chat Completions format — routing through the AWF Copilot proxy at port 10002 with OPENAI_API_KEY (GitHub Copilot token) for auth. The proxy then writes token usage to token_usage.jsonl. ✅

Local validation: make fmt, make test-unit, make check-stale-lock-files — all pass. 256/256 workflows compiled. A maintainer /smoke-opencode re-trigger is needed to verify CI.

…c-engine-syntax

Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>

Copilot AI commented Jul 10, 2026

Copy link
Copy Markdown
Contributor Author

@copilot please run the pr-finisher skill, address unresolved review comments if any, and rerun checks once the branch is up to date.

...

  • ✅ Reviews — All 4 in-scope review threads (r3551263720, r3551263753, r3551263780, r3551263802) are confirmed is_resolved: true via the GitHub API.
  • ✅ Checks (local) — make fmt, make lint, make test-unit, make check-stale-lock-files, make agent-report-progress all pass. 256/256 workflows compiled, 0 errors. Working tree clean.
  • ❓ Checks (CI) — Stale after agent push. The last Smoke OpenCode run (29115970943, SHA 76b75533) failed check_token_telemetry — all token_usage.jsonl paths were missing. This was fixed in commits 671bfeb and 20868ae (disabled the opencode provider, routed through AWF Copilot proxy with providers.openai.apiKey placeholder, set OPENAI_BASE_URL). A maintainer /smoke-opencode re-trigger is needed to confirm CI green on the latest commits.
  • ✅ Mergeable — Merged main (adds gVisor runtime support feat: add sandbox.agent.runtime: gvisor for gVisor container runtime support #44796 and govulncheck update Update govulncheck dependency to golang.org/x/vuln v1.6.0 #44793). No conflicts.

Hand-off: CI must be re-triggered by a maintainer (/smoke-opencode) before merge.

@pelikhan

Copy link
Copy Markdown
Collaborator

/smoke-opencode

@github-actions

github-actions Bot commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

⚠️ Smoke OpenCode failed. OpenCode encountered unexpected challenges...

@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot please run the pr-finisher skill, address any unresolved review feedback, investigate the recent OpenCode smoke failure, and rerun checks once the branch is ready.

Generated by 👨‍🍳 PR Sous Chef · 7.17 AIC · ⌖ 7.25 AIC · ⊞ 7.5K ·
Comment /souschef to run again

Copilot AI and others added 2 commits July 10, 2026 20:55
…rovider block

Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>
…rovider.openai block

Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>

Copilot AI commented Jul 10, 2026

Copy link
Copy Markdown
Contributor Author

@copilot please run the pr-finisher skill, address any unresolved review feedback, investigate the recent OpenCode smoke failure, and rerun checks once the branch is ready.

...

Fixed in the latest commit.

Root cause (run §29121662603): OpenCode v1.2.14's config schema rejects "providers" (plural) with ConfigInvalidError: Unrecognized key: "providers", causing the Execute OpenCode CLI step to fail immediately before any inference occurred.

The "providers" key was introduced in commit 671bfeb to inject a placeholder apiKey so credential isolation wouldn't break the openai provider — but it used the wrong key name. OpenCode only accepts "provider" (singular).

Fix: Removed the invalid "providers" block and moved "apiKey": "awf-copilot-proxy" into the existing "provider"."openai" object. Updated the unit test accordingly. 256 workflows recompiled, all tests pass.

A maintainer /smoke-opencode re-trigger is needed to confirm CI green.

@gh-aw-bot

Copy link
Copy Markdown
Collaborator

pr-sous-chef

@copilot please run the pr-finisher skill, address unresolved review comments, refresh the branch if needed, and rerun checks once the branch is up to date.

Generated by 👨‍🍳 PR Sous Chef · 10.4 AIC · ⌖ 4.92 AIC · ⊞ 7.5K ·
Comment /souschef to run again

…c-engine-syntax

Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>

Copilot AI commented Jul 10, 2026

Copy link
Copy Markdown
Contributor Author

pr-sous-chef

@copilot please run the pr-finisher skill, address unresolved review comments, refresh the branch if needed, and rerun checks once the branch is up to date....

  • ✅ Reviews — All 4 review threads (r3551263720, r3551263753, r3551263780, r3551263802) confirmed is_resolved: true.
  • ✅ Checks (local) — make fmt, make test-unit, make agent-report-progress all pass. 256 workflows compiled, 0 errors. Lock files in sync.
  • ❓ Checks (CI) — Stale after agent push. Last smoke-opencode run (29121662603) failed on commit d1f28cbf; the providersprovider config fix was committed in d5f6e04 after that run. A maintainer /smoke-opencode re-trigger is needed to confirm CI green on the latest HEAD.
  • ✅ Mergeable — Branch merged with main (ed45400, pr-sous-chef rolling issue thread). No conflicts.

Hand-off: CI must be re-triggered by a maintainer (/smoke-opencode) before merge.

@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot please run the pr-finisher skill, address any remaining review feedback, and rerun checks once the branch is up to date.

Generated by 👨‍🍳 PR Sous Chef · 12.5 AIC · ⌖ 5.63 AIC · ⊞ 7.5K ·
Comment /souschef to run again

Copilot AI commented Jul 10, 2026

Copy link
Copy Markdown
Contributor Author

@copilot please run the pr-finisher skill, address any remaining review feedback, and rerun checks once the branch is up to date.

...

  • ✅ Reviews — All 4 review threads (r3551263720, r3551263753, r3551263780, r3551263802) are confirmed is_resolved: true.
  • ✅ Checks (local) — make fmt, make lint, make test-unit, make check-stale-lock-files, make agent-report-progress all pass. 256/256 workflows compiled, 0 errors. Working tree clean.
  • ❓ Checks (CI) — Stale after the last agent push. The CI runs on HEAD (e358bc8) are action_required, waiting for maintainer approval to run. The most recent smoke-opencode run (29121662603, commit d1f28cbf) failed before the config fixes in commits 20868ae, 671bfeb, and d5f6e04. Those commits fixed: (1) disabled the opencode provider so calls route through AWF Copilot proxy, (2) added providers.openai.apiKey placeholder for credential isolation, (3) fixed providersprovider key. A maintainer needs to re-trigger /smoke-opencode to confirm CI green on the latest HEAD.
  • ✅ Mergeable — Branch is up to date with main, no conflicts.

Actions taken: none — all fixes were already committed in prior iterations. No uncommitted changes.

Hand-off: CI must be re-triggered by a maintainer (/smoke-opencode) before merge.

@gh-aw-bot

Copy link
Copy Markdown
Collaborator

pr-sous-chef

@copilot please run the pr-finisher skill, address the remaining unresolved review feedback, and rerun checks once the branch is up to date.

Unresolved review feedback to address:

Generated by 👨‍🍳 PR Sous Chef · 13.9 AIC · ⌖ 4.91 AIC · ⊞ 7.5K ·
Comment /souschef to run again

Copilot AI commented Jul 10, 2026

Copy link
Copy Markdown
Contributor Author

pr-sous-chef

@copilot please run the pr-finisher skill, address the remaining unresolved review feedback, and rerun checks once the branch is up to date....

  • ✅ Reviews — All 4 review threads (r3551263720, r3551263753, r3551263780, r3551263802) are confirmed is_resolved: true via the GitHub API. The pr-sous-chef report listing r3551263720 as unresolved was stale.
  • ✅ Checks (local) — make fmt, make test-unit, make check-stale-lock-files, make agent-report-progress all pass. 256/256 workflows compiled, 0 errors. Working tree clean.
  • ❓ Checks (CI) — Stale after last agent push (e358bc8). The most recent smoke-opencode run (29121662603) was on commit d1f28cbf before the providersprovider config fix in d5f6e04. A maintainer /smoke-opencode re-trigger is needed to confirm CI green on HEAD.
  • ✅ Mergeable — Branch is up to date with main, no conflicts.

Actions taken: none — all threads are already resolved and local validation is green. Hand-off: CI must be re-triggered by a maintainer (/smoke-opencode) before merge.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants