Skip to content

refactor(agent-core-v2): drop the unused AgentPhase status union - #3760

Open
sailist wants to merge 1 commit into
MoonshotAI:devfrom
sailist:refact-212-09-14-drop-agent-phase
Open

refactor(agent-core-v2): drop the unused AgentPhase status union#3760
sailist wants to merge 1 commit into
MoonshotAI:devfrom
sailist:refact-212-09-14-drop-agent-phase

Conversation

@sailist

@sailist sailist commented Sep 14, 2026

Copy link
Copy Markdown
Collaborator

Related Issue

None — internal cleanup (dead type removal).

Problem

AgentPhase (a 7-kind union: idle/running/tool_call/retrying/awaiting_approval/interrupted/ended) was declared in agent-core-v2 as the wire shape of agent.status.updated, but nothing ever produced or consumed it: every AgentStatusUpdated emission omits phase, and the single consumer of the event interface never reads it. Three of its kinds (awaiting_approval, interrupted, ended) are not agent-machine states at all — they are echoes of turn domain events and the permission interaction system. The authoritative agent state set is the xstate machine projection (LoopSnapshot.state idle/running + MachineEngineTurnSnapshot.phase running/tool_call/retrying), which flows to clients via the agent.state message and is unaffected by this declaration.

The klient contract also declared phase: z.string().optional() for agent.status.updated — never populated and wrongly typed (the declared AgentPhase was an object, not a string).

What changed

  • Removed the unused AgentPhase union and the phase field from AgentStatusUpdatedEvent in packages/agent-core-v2/src/agent/usage/usageEvents.ts (plus the now-unused TurnEndReason import).
  • Removed the never-populated phase field from the agent.status.updated schema in packages/klient/src/contract/agent/events.ts.
  • Fixed a dead call in apps/kimi-inspect/src/panels.ts: the AgentLoopService panel fetched activitySnapshot, which does not exist on IAgentLoopService; it now fetches snapshot().

No behavior change: agent.state wire turn.status, LoopSnapshot.turn.phase, and all durable turn events are untouched. Phase is derived live from the machine and never persisted, so there is no migration surface.

Checklist

  • I have read the CONTRIBUTING document.
  • I have linked a related issue (external PRs: the issue must have a maintainer's /approve). — N/A, internal cleanup, no issue.
  • I have added tests that prove my feature works. — No new tests: dead-code removal with no behavior change; the existing suite (15655 tests, green remotely) covers regressions.
  • Ran gen-changesets skill, or this PR needs no changeset. — No changeset: not user-perceivable.
  • Ran gen-docs skill, or this PR needs no doc update. — No doc update needed.

@changeset-bot

changeset-bot Bot commented Sep 14, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 2ad3816

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@pkg-pr-new

pkg-pr-new Bot commented Sep 14, 2026

Copy link
Copy Markdown
pnpm dlx https://pkg.pr.new/@moonshot-ai/kimi-code@2ad3816
npx https://pkg.pr.new/@moonshot-ai/kimi-code@2ad3816

commit: 2ad3816

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant