kimi-code icon indicating copy to clipboard operation
kimi-code copied to clipboard

[Bug] --agent <name> hard-crashes in headless print mode: EventBus "agent.activity.updated has no active lifecycle context"

Open NashCC1550 opened this issue 3 months ago • 1 comments

Environment

  • kimi-code v0.38.0 (latest), macOS arm64, installed via official install script
  • Invocation: headless print mode (-p)

Reproduction

kimi --agent dev -p "hi"

Also crashes identically with a deliberately nonexistent profile name (--agent nonexistent-probe), so the crash is not dependent on profile content or discovery success.

Expected

Session starts with the named agent profile, or a clean "profile not found" error.

Actual

Hard crash before any session activity:

Error: Agent event 'agent.activity.updated' has no active lifecycle context
    at EventBusService.publish (main.cjs:255710:112)
    at AgentEventBusView.publish (main.cjs:255760:13)
    at EventDispatcherService.executeEvent (main.cjs:256279:56)
    at EventDispatcherService.runDispatch (main.cjs:256224:9)
    at EventDispatcherService.dispatch (main.cjs:256194:10)
    at AgentActivityView.publish (main.cjs:273146:20)

Notes / workaround

  • --agent-file <path> works fine in print mode — the profile loads and is honored (verified with a project-local profile; the agent correctly self-reports its profile name). So the profile loading path is healthy; only the --agent <name> discovery/dispatch path crashes.
  • Mirror-image issue on the other surface: #2767 (--agent-file ignored in TUI but works in -p). Together these suggest the custom-profile wiring differs between TUI and headless in two opposite ways.
  • Agent profile discovery dirs observed from the binary: project .kimi-code/agents / .agents/agents, user .agents/agents. (As an aside: it would be helpful if the docs page for agents/sub-agents listed these explicitly.)

NashCC1550 avatar Aug 26 '26 09:08 NashCC1550

Re-tested on kimi-code 2.1.1 (macOS arm64): this is fixed.

  • kimi --agent nonexistent-probe -p "hi" now exits cleanly with Unknown agent profile: "nonexistent-probe". Available profiles: plan, agent, coder, explore (rc=1), no EventBus crash.
  • kimi --agent explore -p "Reply with exactly: OK" runs normally and replies OK (rc=0).

Closing — thanks!

NashCC1550 avatar Oct 07 '26 01:10 NashCC1550