MoonshotAI / MoonshotAI/kimi-code

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

Open
#3,264 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
7.5k
Forks
1.2k
Avg merge
11h 53m
Merged PRs (30d)
350

Description

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.)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce with kimi --agent dev -p "hi" and the nonexistent profile variant, then trace the headless dispatch path around EventBusService.publish, AgentEventBusView.publish, and AgentActivityView.publish in the reported main.cjs stack. Compare this with the working --agent-file path and inspect the profile discovery directories named in the issue. Done means a named profile starts successfully in print mode, while a missing profile produces a clean error instead of a lifecycle-context crash.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
67/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.