Add models check step for engine API access verification#28316
Add models check step for engine API access verification#28316
Conversation
- Add ModelsRoute struct and ModelsProvider optional interface to agentic_engine.go - Add ModelsCheckStepID constant to pkg/constants/job_constants.go - Implement ModelsProvider in ClaudeEngine (Anthropic /v1/models endpoint) - Implement ModelsProvider in CodexEngine (OpenAI /v1/models endpoint) - Add generateModelsCheckStep() to compiler_yaml_ai_execution.go - Call models check step before agent execution in compiler_yaml_main_job.go - Add models_check_failed job output in compiler_main_job.go - Pass GH_AW_MODELS_CHECK_FAILED to conclusion job in notify_comment.go - Handle GH_AW_MODELS_CHECK_FAILED in handle_agent_failure.cjs - Update agent_failure_issue.md and agent_failure_comment.md templates - Add comprehensive tests in models_check_test.go - Recompile all workflow lock files Agent-Logs-Url: https://github.com/github/gh-aw/sessions/c09a4bb3-e0c4-41b9-877d-fda0b4f33849 Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
|
@copilot you must also add support for the api base url |
- Add BaseURLEnvVar, BaseURLEnvExpr, ModelsPath fields to ModelsRoute - ClaudeEngine.GetModelsRoute reads ANTHROPIC_BASE_URL from engine.env - CodexEngine.GetModelsRoute reads OPENAI_BASE_URL from engine.env - generateModelsCheckStep uses dynamic bash URL resolution when base URL configured - Add tests for custom base URL from engine.env for both Claude and Codex Agent-Logs-Url: https://github.com/github/gh-aw/sessions/7202e391-e8d4-4618-b88d-aaf9d212f6f3 Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Done in 177a205. The models check step now reads Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
|
@copilot you need to pass the env var to the steps so that it reads it |
The bash conditional `${ANTHROPIC_BASE_URL:-}` / `${OPENAI_BASE_URL:-}` in the models check
step was only useful if the env var was actually visible to the step. GitHub Actions variables
(vars.*) are NOT automatically available as process env vars - they must be explicitly mapped
in the step's `env:` block.
Now the step always includes the base URL env var:
- With the explicit value from engine.env when configured there
- Otherwise mapped from `${{ vars.ANTHROPIC_BASE_URL || '' }}` (GitHub Actions variable)
This ensures users who set ANTHROPIC_BASE_URL / OPENAI_BASE_URL as a GitHub Actions variable
have it picked up by the models check step.
Agent-Logs-Url: https://github.com/github/gh-aw/sessions/8b7f7a7a-b8a1-4735-b653-54def4808dff
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Fixed in 1aa8b23. The step now always includes the base URL env var in its Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
|
@copilot make this step uses the same variables as the agent step. Including support for github apps. |
…Apps support)
Refactor generateModelsCheckStep to build its env block the same way the
agent execution step does:
1. Start with the route's default secret expression (e.g. ANTHROPIC_API_KEY)
2. Always expose the base URL env var via ${{ vars.X || '' }} fallback
3. Merge engine.env on top, allowing overrides of any env var
4. Merge agentConfig.Env for full parity with the agent step
This enables the GitHub Apps pattern where ANTHROPIC_API_KEY (or OPENAI_API_KEY)
is provided via engine.env referencing a dynamically minted token from a pre-step
(e.g. ANTHROPIC_API_KEY: ${{ steps.get-app-token.outputs.token }}).
Remove now-dead BaseURLEnvExpr field from ModelsRoute — engine.env is merged
directly so no separate extraction is needed.
Add TestModelsCheckEngineEnvOverridesAPIKey test to verify the override behavior.
Agent-Logs-Url: https://github.com/github/gh-aw/sessions/7defaa7b-6ae0-49af-bb2d-47e707dcb3c1
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
…agic string in test Agent-Logs-Url: https://github.com/github/gh-aw/sessions/7defaa7b-6ae0-49af-bb2d-47e707dcb3c1 Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Done in 4627eef. The models check step now builds its env block the same way as the agent execution step:
The now-dead Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
Summary
Adds a pre-agent step that requests the list of models from the agentic engine provider before the agent step is launched, verifying API access and surfacing secret validity issues early.
Changes
New interface:
ModelsProviderDefines an optional
ModelsProviderinterface in the agentic engine architecture:Along with a
ModelsRoutestruct that captures the URL, auth header, auth scheme, secret env var, secret expression, extra headers, and base URL env var configuration.Engine implementations
ClaudeEngine: ImplementsModelsProviderusinghttps://api.anthropic.com/v1/modelswithx-api-keyauth andanthropic-version: 2023-06-01header. RespectsANTHROPIC_BASE_URLfromengine.envfor custom API endpoints. Skipped when custom command or top-levelenvironment:is configured.CodexEngine: ImplementsModelsProviderusinghttps://api.openai.com/v1/modelswithAuthorization: Bearerauth. RespectsOPENAI_BASE_URLfromengine.envfor custom API endpoints. Skipped when custom command or top-levelenvironment:is configured.Generated step: "Verify engine API access"
When an engine implements
ModelsProvider, a bash step is emitted before the agent execution step that:${ANTHROPIC_BASE_URL%/}/models(or${OPENAI_BASE_URL%/}/models) when the base URL env var is set, falling back to the default endpoint otherwise/modelsendpoint usingcurlwith the engine's secret✅ Engine API access verifiedand lists available models inGITHUB_STEP_SUMMARYmodels_check_failed=truein step output, reports❌ Models request failedtoGITHUB_STEP_SUMMARY, and exits 1 (failing the job)Environment variable parity with the agent step
The models check step builds its
env:block using the same layered approach as the agent execution step:ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }})${{ vars.ANTHROPIC_BASE_URL || '' }}so GitHub Actions variables are visible to the bash script (they are not automatically available as process env vars)engine.envmerge — any user-configured override takes precedence, overwriting the defaults above. This enables the GitHub Apps pattern where a token minted in a pre-step is passed asANTHROPIC_API_KEY: ${{ steps.get-app-token.outputs.token }}inengine.env, and both the models check step and the agent step use the same dynamic credentialagentConfig.Envmerge — for full parity with the agent execution stepCustom API base URL support
When
ANTHROPIC_BASE_URLorOPENAI_BASE_URLis set inengine.env, the models check step hits the same custom endpoint the agent will use. When not set inengine.env, the base URL env var is still mapped from the GitHub Actions variable (${{ vars.ANTHROPIC_BASE_URL || '' }}) so it can be configured at the repository/organisation level without touching the workflow file.Job output and conclusion job integration
models_check_failedas a job output (defaults to'false')GH_AW_MODELS_CHECK_FAILEDfrom the agent job outputhandle_agent_failure.cjsreads this env var and adds a**⚠️ Engine API Access Failed**context to the failure issue/comment, indicating the secret may be incorrect or outdated{models_check_failed_context}placeholder is added to bothagent_failure_issue.mdandagent_failure_comment.mdtemplates (right after{secret_verification_context}, reusing the same issue)Testing
Added
pkg/workflow/models_check_test.gowith tests covering:models_check_failedjob output added whenModelsProvideris implementedGH_AW_MODELS_CHECK_FAILEDpassed to conclusion jobModelsProvider)environment:is configuredANTHROPIC_BASE_URLfromengine.envis used in the generated step for ClaudeOPENAI_BASE_URLfromengine.envis used in the generated step for Codexengine.envAPI key override replaces the default secret expression in the models check step (GitHub Apps pattern)