MoonshotAI / MoonshotAI/kimi-code

Add a native completed-turn hook for bounded memory capture

Open
#3,565 0 comments 0 reactions 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

Kimi hook request: native completed-turn event for bounded memory capture

Summary

Kimi plugins cannot automatically retain the final user/assistant exchange.
Stop exposes stop_hook_active, StopFailure exposes an error, and
SessionEnd exposes a reason, but none provides the final user-visible answer
with stable product turn correlation.

Requested event

Add an observation-only completed-turn event carrying bounded structured data:

{
  "hook_event_name": "TurnCompleted",
  "conversation_key": "product-conversation-id",
  "turn_id": "product-turn-id",
  "prompt": [{"type": "text", "text": "user text"}],
  "response": [{"type": "text", "text": "final assistant text"}],
  "outcome": "completed"
}

The event should also represent cancelled, blocked, and failed outcomes
without fabricating a response. It must fire after the final answer is secured,
not for stream deltas, reasoning, tool requests, or intermediate messages.

Required semantics

  • Product conversation_key + turn_id matches the pre-answer identity and is
    stable across callback retry.
  • Retried delivery of one event preserves the same identity.
  • The final response is exactly the user-visible answer and excludes hidden
    reasoning by contract.
  • Payload sizes and content-part types are documented and bounded.
  • Hook failure never delays, changes, or erases the completed Kimi answer.
  • Private/incognito sessions can disable the event through an app-owned policy.

Use case

A memory plugin can strip its own injected wrappers, apply user-approved
privacy/size rules, and send one idempotent retain operation to an existing
memory authority. Without this native event, alternatives require transcript
database reads, UI scraping, log parsing, or a second permanent client—all less
private and less reliable than an app-owned lifecycle callback.

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

No files, tests, or entry points are named. Start by tracing the existing Stop, StopFailure, and SessionEnd hook paths and how final answers are secured and correlated. Done means a bounded TurnCompleted event covers each outcome with stable retry identity, documented content limits, privacy policy support, and no impact when delivery fails.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
cli
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.