Skip to content

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

Description

@NashCC1550

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: TUI ignores --agent-file at launch; startup session binds default agent (works in -p print mode) #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.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions