Skip to content

fix(gateway): boot-md hook inherits model/provider/api_mode from config.yaml#11069

Open
saamuelng601-pixel wants to merge 1 commit into
NousResearch:mainfrom
saamuelng601-pixel:fix/boot-md-inherit-config
Open

fix(gateway): boot-md hook inherits model/provider/api_mode from config.yaml#11069
saamuelng601-pixel wants to merge 1 commit into
NousResearch:mainfrom
saamuelng601-pixel:fix/boot-md-inherit-config

Conversation

@saamuelng601-pixel

Copy link
Copy Markdown

Summary

The built-in boot-md hook (gateway/builtin_hooks/boot_md.py) spawns a one-shot AIAgent on gateway startup without forwarding the user's model configuration. AIAgent.__init__ then falls back to defaults (model="", provider="", api_mode=None), the api_mode resolution chain picks chat_completions, and on an openai-codex setup the boot agent POSTs to chatgpt.com/backend-api/codex/chat/completions — a route the Codex backend does not expose. The backend replies HTTP 404 {"detail":"Not Found"} and the boot checklist is aborted before anything runs.

This is the only AIAgent call in the codebase that skips the standard model-config plumbing — every other caller passes it in explicitly.

Fix

Load ~/.hermes/config.yaml via hermes_cli.config.load_config() inside _run_boot_agent() and forward model / provider / api_mode to AIAgent. Both the current dict shape (model: {default, provider, api_mode}) and the legacy string shape (model: "...") are handled explicitly, matching how runtime_provider.py and web_server.py already read the config.

Repro + verification

On a local install configured with:

model:
  default: gpt-5.4
  provider: openai-codex
  api_mode: codex_responses

Before fix — session 20260416_220458_542285:

  • Request dump URL: https://chatgpt.com/backend-api/codex/chat/completions
  • body.model: ""
  • Result: HTTP 404 {"detail":"Not Found"} — boot agent exits immediately, 0 messages exchanged

After fix — session 20260416_221913_84a6bb:

  • Session model: "gpt-5.4"
  • Base URL resolves to /responses
  • Result: 14 messages exchanged, boot checklist completes

Test plan

  • Existing tests still pass (no new tests added — change is a 15-line init site fix; covered indirectly by the standard AIAgent config path)
  • Manual: restart a gateway configured with openai-codex + non-empty BOOT.md and confirm no Non-retryable client error: 404 in ~/.hermes/logs/errors.log

…ig.yaml

When the boot-md hook spawns its one-shot AIAgent on gateway startup,
it was passing only behavioral flags (quiet_mode, skip_context_files,
skip_memory, max_iterations) and no model configuration. AIAgent.__init__
then fell back to its defaults: model="", provider="" (from None),
api_mode=None. The api_mode resolution chain checks self.provider in
order; with an empty provider, all elif branches fail and api_mode
lands on "chat_completions".

On an openai-codex setup that resolves base_url from state to
https://chatgpt.com/backend-api/codex/, the agent then POSTs to
/chat/completions — a route the Codex backend does not expose (only
/responses exists on the ChatGPT-account tier). The backend replies
HTTP 404 {"detail":"Not Found"} and the boot agent is aborted as a
non-retryable client error.

Fix: read ~/.hermes/config.yaml inside _run_boot_agent() and forward
model/provider/api_mode (from the dict form) or model (from the legacy
string form) to AIAgent so it picks the correct API adapter. This is
the same configuration path every other AIAgent invocation already
uses; only the boot hook was skipping it.

Verified on a local install with model.default=gpt-5.4 via
provider=openai-codex, api_mode=codex_responses:

  Before fix (session 20260416_220458_542285):
    body.model = ""
    url        = https://chatgpt.com/backend-api/codex/chat/completions
    result     = HTTP 404 Not Found, 0 messages exchanged

  After fix  (session 20260416_221913_84a6bb):
    model      = "gpt-5.4"
    url        = https://chatgpt.com/backend-api/codex/responses
    result     = 14 messages exchanged, boot checklist completed

No behavioral change for users who configure model as a plain string
(the legacy shape is handled explicitly).
@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/gateway Gateway runner, session dispatch, delivery labels Apr 25, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Related to #14992 and #12514 — all three PRs fix the same root cause: boot-md hook not forwarding model config to AIAgent.

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

Labels

comp/gateway Gateway runner, session dispatch, delivery P2 Medium — degraded but workaround exists type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants