Skip to content

feat: integrate GitHub Copilot providers across Hermes#1879

Merged
teknium1 merged 1 commit intoNousResearch:mainfrom
mchzimm:feat/copilot-provider-integration
Mar 18, 2026
Merged

feat: integrate GitHub Copilot providers across Hermes#1879
teknium1 merged 1 commit intoNousResearch:mainfrom
mchzimm:feat/copilot-provider-integration

Conversation

@mchzimm
Copy link
Copy Markdown

@mchzimm mchzimm commented Mar 18, 2026

Summary

This PR adds first-class GitHub Copilot integration across Hermes' main CLI/app flows and the messaging gateway stack.

What changed

  • adds copilot as a first-class provider with live GitHub Copilot model catalog support
  • adds copilot-acp as a first-class provider backed by a new OpenAI-compatible copilot --acp shim
  • makes hermes model and hermes setup show real model pickers for Copilot and Copilot ACP
  • normalizes Copilot model IDs and selects the correct runtime API mode (chat_completions vs codex_responses)
  • propagates ACP runtime metadata through CLI sessions, smart routing, delegated subagents, cron jobs, the ACP adapter, and the Telegram gateway
  • trims Copilot Responses API payloads to a safer Copilot-compatible shape
  • fixes gateway/service-mode Copilot auth by resolving Homebrew-installed gh binaries under launchd
  • updates user-facing docs for the new providers and environment variables

Why

This makes GitHub Copilot usable end-to-end in Hermes:

  • the main Hermes app can select and run Copilot models cleanly
  • the Telegram bot and other gateway flows can use the same Copilot runtime reliably
  • Copilot ACP sessions can run as a native Hermes provider instead of a one-off local hack

Release metadata

  • semver: 0.4.0
  • tag: v2026.3.18

Testing

./venv/bin/pytest -q \
  tests/test_cli_provider_resolution.py \
  tests/test_runtime_provider_resolution.py \
  tests/test_api_key_providers.py \
  tests/test_model_provider_persistence.py \
  tests/hermes_cli/test_model_validation.py \
  tests/hermes_cli/test_setup_model_provider.py \
  tests/test_run_agent.py \
  tests/test_run_agent_codex_responses.py \
  tests/agent/test_auxiliary_client.py \
  tests/tools/test_delegate.py \
  tests/cron/test_scheduler.py

Passed: 523 passed

Add first-class GitHub Copilot and Copilot ACP provider support across
model selection, runtime provider resolution, CLI sessions, delegated
subagents, cron jobs, and the Telegram gateway.

This also normalizes Copilot model catalogs and API modes, introduces a
Copilot ACP OpenAI-compatible shim, and fixes service-mode auth by
resolving Homebrew-installed gh binaries under launchd.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings March 18, 2026 06:41
Copy link
Copy Markdown

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 integrates GitHub Copilot as a first-class inference provider across Hermes’ CLI, runtime provider resolution, agent execution paths, and gateway/cron routing—adding both a direct Copilot API provider (copilot) and a local external-process-backed ACP provider (copilot-acp).

Changes:

  • Add new providers (copilot, copilot-acp) with live Copilot model catalog support, model-id normalization, and API mode selection (chat_completions vs codex_responses).
  • Propagate ACP runtime metadata (command, args) through CLI sessions, smart routing, delegation, cron jobs, and gateway flows; add an OpenAI-compatible ACP client shim.
  • Update docs and expand test coverage to validate provider resolution, persisted config, and Copilot-specific request shaping.

Reviewed changes

Copilot reviewed 26 out of 26 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
website/docs/user-guide/configuration.md Documents Copilot/Copilot ACP setup and provider usage in config.
website/docs/reference/environment-variables.md Updates provider override documentation for the new provider.
website/docs/reference/cli-commands.md Updates CLI --provider reference to reflect provider additions.
tools/delegate_tool.py Propagates ACP runtime details to delegated child agents; fixes tool-name restoration handling.
tests/test_run_agent_codex_responses.py Adds Copilot Responses payload-shaping tests.
tests/test_run_agent.py Adds reasoning/Copilot ACP client selection tests.
tests/test_model_provider_persistence.py Ensures Copilot/Copilot ACP selections persist correctly to config.
tests/test_api_key_providers.py Adds registry, aliasing, auth-status, and runtime-resolution tests for Copilot providers.
tests/hermes_cli/test_setup_model_provider.py Verifies hermes setup flows for Copilot and Copilot ACP model pickers.
tests/hermes_cli/test_model_validation.py Adds Copilot catalog probing, reasoning-effort, normalization, and API-mode tests.
tests/agent/test_auxiliary_client.py Confirms auxiliary client uses Copilot runtime credentials/headers.
run_agent.py Adds ACP client wiring and Copilot-specific payload adjustments for Responses/reasoning.
pyproject.toml Bumps project version to 0.4.0.
hermes_cli/setup.py Adds Copilot/Copilot ACP setup flows, model picker integration, and reasoning selection.
hermes_cli/runtime_provider.py Adds Copilot ACP runtime resolver + Copilot dynamic API-mode selection.
hermes_cli/models.py Introduces Copilot catalog fetch, model normalization, API-mode inference, and reasoning-effort helpers.
hermes_cli/main.py Adds hermes model flows for Copilot and Copilot ACP, plus reasoning-effort selection.
hermes_cli/auth.py Registers providers; adds gh auth token fallback + external-process provider credential resolution.
hermes_cli/init.py Bumps Hermes CLI version/date metadata.
gateway/run.py Propagates ACP command/args into gateway runtime kwargs.
cron/scheduler.py Propagates ACP command/args into cron job agent construction.
cli.py Adds Copilot model normalization + API-mode adjustment and propagates ACP metadata.
agent/smart_model_routing.py Extends routing signatures/runtime payloads to include ACP command/args.
agent/copilot_acp_client.py Adds Copilot ACP OpenAI-compatible client shim that spawns copilot --acp --stdio.
agent/auxiliary_client.py Uses runtime credential resolver for API-key providers; adds Copilot default headers.
acp_adapter/session.py Propagates ACP runtime metadata through ACP adapter session creation.

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

You can also share your feedback on Copilot code review. Take the survey.

| Variable | Description |
|----------|-------------|
| `HERMES_INFERENCE_PROVIDER` | Override provider selection: `auto`, `openrouter`, `nous`, `openai-codex`, `anthropic`, `zai`, `kimi-coding`, `minimax`, `minimax-cn`, `kilocode`, `alibaba` (default: `auto`) |
| `HERMES_INFERENCE_PROVIDER` | Override provider selection: `auto`, `openrouter`, `nous`, `openai-codex`, `copilot`, `anthropic`, `zai`, `kimi-coding`, `minimax`, `minimax-cn`, `kilocode`, `alibaba` (default: `auto`) |
| `-m`, `--model <model>` | Override the model for this run. |
| `-t`, `--toolsets <csv>` | Enable a comma-separated set of toolsets. |
| `--provider <provider>` | Force a provider: `auto`, `openrouter`, `nous`, `openai-codex`, `anthropic`, `zai`, `kimi-coding`, `minimax`, `minimax-cn`. |
| `--provider <provider>` | Force a provider: `auto`, `openrouter`, `nous`, `openai-codex`, `copilot`, `anthropic`, `zai`, `kimi-coding`, `minimax`, `minimax-cn`. |
Comment on lines +1383 to +1401
if resolved_provider == "copilot":
try:
from hermes_cli.models import copilot_model_api_mode, normalize_copilot_model_id

canonical = normalize_copilot_model_id(current_model, api_key=self.api_key)
if canonical and canonical != current_model:
if not self._model_is_default:
self.console.print(
f"[yellow]⚠️ Normalized Copilot model '{current_model}' to '{canonical}'.[/]"
)
self.model = canonical
current_model = canonical
changed = True

resolved_mode = copilot_model_api_mode(current_model, api_key=self.api_key)
if resolved_mode != self.api_mode:
self.api_mode = resolved_mode
changed = True
except Exception:
Comment on lines +728 to +736
def _copilot_catalog_ids(
catalog: Optional[list[dict[str, Any]]] = None,
api_key: Optional[str] = None,
) -> set[str]:
if catalog is None and api_key:
catalog = fetch_github_model_catalog(api_key=api_key)
if not catalog:
return set()
return {
Comment on lines +396 to +405
if method == "session/request_permission":
response = {
"jsonrpc": "2.0",
"id": message_id,
"result": {
"outcome": {
"outcome": "allow_once",
}
},
}
teknium1 pushed a commit that referenced this pull request Mar 18, 2026
…ation

Builds on PR #1879's Copilot integration with critical auth improvements
modeled after opencode's implementation:

- Add hermes_cli/copilot_auth.py with:
  - OAuth device code flow (copilot_device_code_login) using the same
    client_id (Ov23li8tweQw6odWQebz) as opencode and Copilot CLI
  - Token type validation: reject classic PATs (ghp_*) with a clear
    error message explaining supported token types
  - Proper env var priority: COPILOT_GITHUB_TOKEN > GH_TOKEN > GITHUB_TOKEN
    (matching Copilot CLI documentation)
  - copilot_request_headers() with Openai-Intent, x-initiator, and
    Copilot-Vision-Request headers (matching opencode)

- Update auth.py:
  - PROVIDER_REGISTRY copilot entry uses correct env var order
  - _resolve_api_key_provider_secret delegates to copilot_auth for
    the copilot provider with proper token validation

- Update models.py:
  - copilot_default_headers() now includes Openai-Intent and x-initiator

- Update main.py:
  - _model_flow_copilot offers OAuth device code login when no token
    is found, with manual token entry as fallback
  - Shows supported vs unsupported token types

- 22 new tests covering token validation, env var priority, header
  generation, and integration with existing auth infrastructure
@teknium1 teknium1 merged commit 8422196 into NousResearch:main Mar 18, 2026
3 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants