feat: add models endpoint querying to agentic engine JS harness (all engines)#28579
feat: add models endpoint querying to agentic engine JS harness (all engines)#28579
Conversation
- Add ModelsEndpointProvider interface to agentic engine (agentic_engine.go) - Implement GetModelsEndpoint() for CopilotEngine returning https://api.githubcopilot.com/models - Add generateAgentModelsStep() to compiler_yaml_ai_execution.go - Wire models step into compiler_yaml_main_job.go before agent execution - Create agent_models.cjs for fetching models and writing agents.json - Create agent_models.test.cjs with 19 unit tests - Update all golden test files to include the new pre-agent step - Recompile all 202 workflow .lock.yml files Agent-Logs-Url: https://github.com/github/gh-aw/sessions/a52a9d81-6d9f-4942-9b6e-99059098461f Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
|
@copilot do not emit step, query from the agent JavaScript driver / harness |
…s harness Instead of emitting a separate 'Query agent models' github-script step, pass GH_AW_MODELS_ENDPOINT and GH_AW_ENGINE_VERSION as env vars on the execution step and have copilot_driver.cjs call queryModels() before the retry loop. - Remove generateAgentModelsStep() from compiler_yaml_ai_execution.go - Remove step call from compiler_yaml_main_job.go - Add GH_AW_MODELS_ENDPOINT + GH_AW_ENGINE_VERSION to CopilotEngine execution env - Add queryModels() to agent_models.cjs (no core.* dependency, takes logFn callback) - Call queryModels() from copilot_driver.cjs before agent retry loop - Refactor logModels() to accept logFn parameter instead of using global core - Update agent_models.test.cjs to cover new queryModels() API - Regenerate all golden files and 202 lock.yml files Agent-Logs-Url: https://github.com/github/gh-aw/sessions/f9c034ab-2b6d-4b23-b519-84130ca3f905 Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Done in 8580a17. The separate
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:
|
|
ignore the "static" version, the driver should run the agent version command to get the actual version number failure to query models endpoint should be warning, not stop the rest of the execution |
…c env var - Add getAgentVersion(command) to copilot_driver.cjs: runs `command --version`, parses first semver token with /v?(\d+\.\d+\.\d+)/, returns "unknown" on failure - Use dynamically obtained version in queryModels() call (replaces static GH_AW_ENGINE_VERSION) - Make unexpected errors in models query explicitly warn and continue (not stop execution) - Remove GH_AW_ENGINE_VERSION from execution step env in copilot_engine_execution.go - Export getAgentVersion for testing; add 3 tests in copilot_driver.test.cjs - Regenerate all golden files and 202 lock.yml files Agent-Logs-Url: https://github.com/github/gh-aw/sessions/995a3434-3e79-4cee-b148-fd7e1636987f Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Done in 89f73a0:
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:
|
pelikhan
left a comment
There was a problem hiding this comment.
@copilot the agentic engine should provide the route (usually /models), then the JavaScript should use the configured API BASE environement variable to assemble the models URL that will work within the gateway. This is meant to run from the gateway.
The agent_models is meant to be invoked from the driver JavaScript .
| */ | ||
|
|
||
| const fs = require("fs"); | ||
| const https = require("https"); |
…OPILOT_BASE_URL; use fetch - Rename ModelsEndpointProvider → ModelsRouteProvider; GetModelsEndpoint() → GetModelsRoute() returns just "/models" (route path, not full URL) - Emit GH_AW_MODELS_ROUTE env var (route only) instead of full URL - copilot_driver.cjs: construct URL from (GITHUB_COPILOT_BASE_URL || default) + route so requests are correctly routed through the gateway - agent_models.cjs: replace https/http modules with native fetch (Node 24) - agent_models.cjs: main() reads GH_AW_MODELS_ROUTE + GITHUB_COPILOT_BASE_URL to assemble URL - Update tests: new env var names, URL assembly test, DEFAULT_COPILOT_BASE_URL constant test - Regenerate all golden files and 202 lock.yml files Agent-Logs-Url: https://github.com/github/gh-aw/sessions/09aa3874-f957-4ba0-88a7-0b9c34764670 Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Done in 91b08fc:
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 this must work for all agentic engines |
…ines - Extend ModelsRouteProvider interface with GetModelsBaseURLEnvVar(), GetModelsDefaultBaseURL(), GetModelsTokenEnvVar() methods - Implement ModelsRouteProvider for CopilotEngine, ClaudeEngine, CodexEngine, and GeminiEngine with engine-specific values - Add applyModelsRouteEnvVarsToMap() shared helper that emits GH_AW_MODELS_ROUTE, GH_AW_MODELS_BASE_URL_ENV, GH_AW_MODELS_DEFAULT_BASE_URL, and GH_AW_MODELS_TOKEN_ENV - Add generateModelsQueryPreamble() that injects a node call into non-driver engine shell commands (AWF + non-AWF modes) - Inject models query preamble into Claude, Codex, Gemini commands - Update copilot_driver.cjs to use generic GH_AW_MODELS_BASE_URL_ENV and GH_AW_MODELS_TOKEN_ENV instead of hardcoded Copilot vars - Add resolveModelsEndpoint() and resolveModelsToken() helpers in agent_models.cjs for any-engine URL/token resolution - Update main() and standalone runner to use generic env vars - Fix GeminiEngineFirewallIntegration test assertion for new env vars - Recompile all 202 workflow lock files and update golden test files Agent-Logs-Url: https://github.com/github/gh-aw/sessions/9a388aa3-0def-4893-bac3-72967ae597cc Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Done in 8ed0028. The mechanism now works for all agentic engines:
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 support for querying the models endpoint of agentic engines before agent execution starts. The fetched model list is stored in
/tmp/gh-aw/agents.json(included in the agent artifact), logged to the driver log, and appended to the step summary as a collapsible<details>section. The query runs directly inside the existing driver harness or as a shell preamble — no separate GitHub Actions step is emitted.Changes
Go — engine layer
pkg/workflow/agentic_engine.goModelsRouteProvideroptional interface withGetModelsRoute(),GetModelsBaseURLEnvVar(),GetModelsDefaultBaseURL(), andGetModelsTokenEnvVar(). Added sharedapplyModelsRouteEnvVarsToMap()andgenerateModelsQueryPreamble()helpers.pkg/workflow/copilot_engine.goCopilotEngineimplements all fourModelsRouteProvidermethods (/models,GITHUB_COPILOT_BASE_URL,https://api.githubcopilot.com,COPILOT_GITHUB_TOKEN).pkg/workflow/claude_engine.goClaudeEngineimplementsModelsRouteProvider(/v1/models,ANTHROPIC_BASE_URL,https://api.anthropic.com,ANTHROPIC_API_KEY). Models query injected as shell preamble before agent command.pkg/workflow/codex_engine.goCodexEngineimplementsModelsRouteProvider(/v1/models,OPENAI_BASE_URL,https://api.openai.com,CODEX_API_KEY). Models query injected as shell preamble.pkg/workflow/gemini_engine.goGeminiEngineimplementsModelsRouteProvider(/v1/models,GEMINI_API_BASE_URL,https://generativelanguage.googleapis.com,GEMINI_API_KEY). Models query injected as shell preamble.pkg/workflow/copilot_engine_execution.goapplyModelsRouteEnvVarsToMap()helper instead of inline code.JavaScript — harness
actions/setup/js/agent_models.cjsqueryModels({ endpoint, token, engineId, engineVersion, agentsJsonPath?, stepSummaryPath?, logFn? })— driver-compatible, nocore.*dependency. Uses nativefetch(Node 24). AddedresolveModelsEndpoint()andresolveModelsToken()helpers that read genericGH_AW_MODELS_BASE_URL_ENV,GH_AW_MODELS_DEFAULT_BASE_URL, andGH_AW_MODELS_TOKEN_ENVenv vars, making the module work with any engine. Standalone runner (require.main === module) uses the same generic env vars — invoked by the shell preamble for non-driver engines.actions/setup/js/copilot_driver.cjsresolveModelsEndpoint()andresolveModelsToken()instead of hardcoded Copilot-specific env vars.getAgentVersion(command)runscommand --versionto dynamically obtain the installed agent version.actions/setup/js/agent_models.test.cjsextractModelsList,buildModelsMarkdown,logModels,resolveModelsEndpoint,resolveModelsToken,queryModels(with in-process HTTP server), andmain()error paths including multi-engine URL assembly.actions/setup/js/copilot_driver.test.cjsgetAgentVersion.Test / lock files
TestWasmGolden_CompileFixtures+WasmBinarysets)..lock.ymlworkflow files recompiled.Behaviour at runtime
copilot_driver.cjsbefore the retry loop.node agent_models.cjsis injected as a best-effort shell preamble before the main agent command (AWF and non-AWF modes).(runtime base URL from GH_AW_MODELS_BASE_URL_ENV || GH_AW_MODELS_DEFAULT_BASE_URL) + GH_AW_MODELS_ROUTE, so requests are always routed through the configured gateway when present.command --versionto obtain the actual installed agent version before querying, ensuringagents.jsonalways reflects the runtime version.GH_AW_MODELS_ROUTEor the auth token env var are absent (e.g. inside the AWF sandbox where secrets are excluded) the query is skipped silently./tmp/gh-aw/agents.jsonis written and the models list appears in the step summary as a collapsible table.agents.json format
{ "<engineId>": { "version": "<actual runtime version from command --version>", "models": { ...raw API response... } } }