Skip to content

fix(gateway): pass model + runtime to BOOT.md startup hook#12514

Closed
C-fog wants to merge 1 commit into
NousResearch:mainfrom
C-fog:feat/fix-boot-md-hook
Closed

fix(gateway): pass model + runtime to BOOT.md startup hook#12514
C-fog wants to merge 1 commit into
NousResearch:mainfrom
C-fog:feat/fix-boot-md-hook

Conversation

@C-fog

@C-fog C-fog commented Apr 19, 2026

Copy link
Copy Markdown

Problem

The gateway:startup hook (boot_md.py) creates a bare AIAgent() without passing model or provider runtime kwargs. When using providers that require a model parameter (e.g. zai/GLM), this causes a 400 model: The model code cannot be empty error. Every boot-md execution silently logs "nothing to report."

Refs #5239

Root Cause

boot_md.py::_run_boot_agent() instantiated AIAgent() with no model argument, defaulting to anthropic/claude-opus-4.6. For non-Anthropic providers, this either fails or uses the wrong model.

Fix

Enrich the gateway:startup hook context with the resolved model name and runtime_kwargs, then extract and pass them to AIAgent() in boot_md.py.

Changes

gateway/run.py (+27/-5):

  • Emit gateway:startup after channel directory is built (so hooks can use send_message with name resolution)
  • Resolve model via _resolve_gateway_model() and runtime kwargs via _resolve_runtime_agent_kwargs()
  • Pass both in the hook context dict with try/except fallback for robustness

gateway/builtin_hooks/boot_md.py (+23/-3):

  • Extract model and runtime_kwargs from hook context
  • Forward to _run_boot_agent()AIAgent(model=model, **runtime_kwargs, ...)
  • Graceful fallback: if context is missing keys, behavior is unchanged from before

Verification

Tested with zai/GLM provider — BOOT.md now successfully reads instructions, calls the LLM, and delivers the startup notification to Feishu:

2026-04-19 17:52:03 boot-md completed: Message sent successfully to Feishu chat oc_e7e081af...
✅ Boot checklist complete — gateway startup test message delivered.

Notes

  • No unit tests added for boot_md (pre-existing code also lacked tests — difficult to unit-test due to AIAgent + gateway runtime dependency)
  • runtime_kwargs may contain api_key but this is safe within the gateway process (same as all other AIAgent call sites)
  • Implementation is consistent with how other gateway components pass model/runtime to AIAgent

The boot-md hook created a bare AIAgent() with no model, provider,
api_key or base_url. The internal auto-resolve chain discards the
resolved model, causing every boot-md API call to fail with:

    400 — 'model: The model code cannot be empty.'

Fix by passing the resolved model and runtime_kwargs through the
gateway:startup hook context, then forwarding them to AIAgent via
**runtime_kwargs — matching the pattern used by every other AIAgent
call site in the gateway.

Also move the gateway:startup emit to after channel directory build
so that hooks can safely use send_message during startup.

Refs: NousResearch#5239
@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 23, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Related to #5240 (same fix for BOOT.md startup hook auth bypass). Maintainers should pick one.

teknium1 added a commit that referenced this pull request Apr 28, 2026
BOOT.md was merged in PR #3733 before the feature was ready — the
built-in hook spawned a bare AIAgent() with no model/runtime kwargs,
which immediately 401s on any provider with a custom endpoint. Three
separate community PRs (#5240, #12514, #14992) tried to paper over it.

Remove the BOOT.md hook entirely and its user-facing docs/tips. Keep
the gateway/builtin_hooks/ package and the HookRegistry._register_builtin_hooks()
hook-point intact as the extension surface for future always-on
gateway hooks.

Closes #5239.

Co-authored-by: teknium1 <teknium@users.noreply.github.com>
@teknium1

Copy link
Copy Markdown
Contributor

Superseded by #17093 — we rolled BOOT.md back entirely rather than layering runtime-resolution fixes on top. The feature shipped in #3733 before it was ready (bare AIAgent() with no model/runtime, as you correctly identified), so pulling it is the right move for now. Thanks for the fix — if we bring BOOT.md back later, we'll do it with the runtime-resolution pattern you PR'd here.

@teknium1 teknium1 closed this Apr 28, 2026
cluricaun28 referenced this pull request in cluricaun28/Logos Apr 28, 2026
BOOT.md was merged in PR #3733 before the feature was ready — the
built-in hook spawned a bare AIAgent() with no model/runtime kwargs,
which immediately 401s on any provider with a custom endpoint. Three
separate community PRs (#5240, #12514, #14992) tried to paper over it.

Remove the BOOT.md hook entirely and its user-facing docs/tips. Keep
the gateway/builtin_hooks/ package and the HookRegistry._register_builtin_hooks()
hook-point intact as the extension surface for future always-on
gateway hooks.

Closes #5239.

Co-authored-by: teknium1 <teknium@users.noreply.github.com>
ulasbilgen pushed a commit to ulasbilgen/hermes-adhd-agent that referenced this pull request May 1, 2026
BOOT.md was merged in PR NousResearch#3733 before the feature was ready — the
built-in hook spawned a bare AIAgent() with no model/runtime kwargs,
which immediately 401s on any provider with a custom endpoint. Three
separate community PRs (NousResearch#5240, NousResearch#12514, NousResearch#14992) tried to paper over it.

Remove the BOOT.md hook entirely and its user-facing docs/tips. Keep
the gateway/builtin_hooks/ package and the HookRegistry._register_builtin_hooks()
hook-point intact as the extension surface for future always-on
gateway hooks.

Closes NousResearch#5239.

Co-authored-by: teknium1 <teknium@users.noreply.github.com>
donald131 pushed a commit to donald131/hermes-agent that referenced this pull request May 2, 2026
BOOT.md was merged in PR NousResearch#3733 before the feature was ready — the
built-in hook spawned a bare AIAgent() with no model/runtime kwargs,
which immediately 401s on any provider with a custom endpoint. Three
separate community PRs (NousResearch#5240, NousResearch#12514, NousResearch#14992) tried to paper over it.

Remove the BOOT.md hook entirely and its user-facing docs/tips. Keep
the gateway/builtin_hooks/ package and the HookRegistry._register_builtin_hooks()
hook-point intact as the extension surface for future always-on
gateway hooks.

Closes NousResearch#5239.

Co-authored-by: teknium1 <teknium@users.noreply.github.com>
@C-fog C-fog deleted the feat/fix-boot-md-hook branch May 3, 2026 15:56
02356abc pushed a commit to 02356abc/hermes-agent that referenced this pull request May 14, 2026
BOOT.md was merged in PR NousResearch#3733 before the feature was ready — the
built-in hook spawned a bare AIAgent() with no model/runtime kwargs,
which immediately 401s on any provider with a custom endpoint. Three
separate community PRs (NousResearch#5240, NousResearch#12514, NousResearch#14992) tried to paper over it.

Remove the BOOT.md hook entirely and its user-facing docs/tips. Keep
the gateway/builtin_hooks/ package and the HookRegistry._register_builtin_hooks()
hook-point intact as the extension surface for future always-on
gateway hooks.

Closes NousResearch#5239.

Co-authored-by: teknium1 <teknium@users.noreply.github.com>
dannyJ848 pushed a commit to dannyJ848/hermes-agent that referenced this pull request May 17, 2026
BOOT.md was merged in PR NousResearch#3733 before the feature was ready — the
built-in hook spawned a bare AIAgent() with no model/runtime kwargs,
which immediately 401s on any provider with a custom endpoint. Three
separate community PRs (NousResearch#5240, NousResearch#12514, NousResearch#14992) tried to paper over it.

Remove the BOOT.md hook entirely and its user-facing docs/tips. Keep
the gateway/builtin_hooks/ package and the HookRegistry._register_builtin_hooks()
hook-point intact as the extension surface for future always-on
gateway hooks.

Closes NousResearch#5239.

Co-authored-by: teknium1 <teknium@users.noreply.github.com>
gweeteve pushed a commit to gweeteve/hermes-agent that referenced this pull request Jun 2, 2026
BOOT.md was merged in PR NousResearch#3733 before the feature was ready — the
built-in hook spawned a bare AIAgent() with no model/runtime kwargs,
which immediately 401s on any provider with a custom endpoint. Three
separate community PRs (NousResearch#5240, NousResearch#12514, NousResearch#14992) tried to paper over it.

Remove the BOOT.md hook entirely and its user-facing docs/tips. Keep
the gateway/builtin_hooks/ package and the HookRegistry._register_builtin_hooks()
hook-point intact as the extension surface for future always-on
gateway hooks.

Closes NousResearch#5239.

Co-authored-by: teknium1 <teknium@users.noreply.github.com>
Egavasyug pushed a commit to Egavasyug/hermes-agent that referenced this pull request Jun 10, 2026
BOOT.md was merged in PR NousResearch#3733 before the feature was ready — the
built-in hook spawned a bare AIAgent() with no model/runtime kwargs,
which immediately 401s on any provider with a custom endpoint. Three
separate community PRs (NousResearch#5240, NousResearch#12514, NousResearch#14992) tried to paper over it.

Remove the BOOT.md hook entirely and its user-facing docs/tips. Keep
the gateway/builtin_hooks/ package and the HookRegistry._register_builtin_hooks()
hook-point intact as the extension surface for future always-on
gateway hooks.

Closes NousResearch#5239.

Co-authored-by: teknium1 <teknium@users.noreply.github.com>
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.

3 participants