update: memoryシステム周りのプロンプトの整理

This commit is contained in:
2026-05-03 00:27:10 +09:00
parent 3bb8af824e
commit 261c682e5e
9 changed files with 189 additions and 33 deletions
+4 -5
View File
@@ -4,13 +4,14 @@
//! 出力を `<workspace>/.insomnia/memory/_staging/<id>.json` に書き出す
//! ヘルパーを提供する。Pod 側はこのモジュールから:
//!
//! - [`EXTRACT_SYSTEM_PROMPT`] を sub-Worker の system prompt に
//! - [`build_extract_input`] を sub-Worker の最初の user 入力に
//! - [`write_extracted_tool`] を唯一のツールとして
//! - [`write_staging`] で受け取った JSON を staging に書き出し
//!
//! の順で組み立てる。pointer 永続化(session-store の
//! `LogEntry::Extension`、domain `"memory.extract"`)は Pod 側が責務を持つ。
//! の順で組み立てる。system prompt は Pod の `PromptCatalog`
//! (`PodPrompt::MemoryExtractSystem`) で管理される。pointer 永続化
//! session-store の `LogEntry::Extension`、domain `"memory.extract"`)は
//! Pod 側が責務を持つ。
//!
//! 出力 JSON の wrap は [`write_staging`] が `source: { session_id, range }`
//! を機械付与する形で担当し、LLM には source を推論させない。
@@ -18,7 +19,6 @@
mod input;
mod payload;
mod pointer;
mod prompt;
mod staging;
mod tool;
@@ -27,7 +27,6 @@ pub use payload::{
AttemptEntry, DecisionEntry, DiscussionEntry, ExtractedPayload, RequestEntry, StagingRecord,
};
pub use pointer::{ExtractPointerPayload, fold_pointer};
pub use prompt::EXTRACT_SYSTEM_PROMPT;
pub use staging::{StagingError, write_staging};
pub use tool::{ExtractWorkerContext, write_extracted_tool};
-32
View File
@@ -1,32 +0,0 @@
//! Phase 1 sub-Worker の system prompt。
//!
//! 内容は `docs/plan/memory-prompts.md` §共通原則 / §Phase 1 を縮約。
//! 「派生物を作らず、起きたことを抽出する」段階に縛り、JSON schema
//! 準拠以外の自由文を許さない。
pub const EXTRACT_SYSTEM_PROMPT: &str = r#"You are the Phase 1 activity extractor for an INSOMNIA memory subsystem.
Your single job: read the supplied conversation slice and emit a structured JSON record of "what happened" via the `write_extracted` tool. You are not consolidating, summarising, or generating knowledge — that is a later phase's job.
# Hard rules
- Call `write_extracted` exactly once. Do not narrate, ask questions, or send any other tool output.
- The argument is an object with four arrays: `decisions`, `discussions`, `attempts`, `requests`. Any of them may be empty. If nothing in the slice is worth recording, call `write_extracted({"decisions": [], "discussions": [], "attempts": [], "requests": []})` and stop.
- Do NOT include `source`, `session_id`, entry indices, timestamps, or any provenance metadata. The wrapper attaches them mechanically.
- Do NOT add free-form commentary, summaries, or explanatory prose outside the schema fields.
# Extraction guidance
- `decisions`: judgements made during the slice. Each entry needs `options` (the alternatives considered), `chosen` (what was picked), and `rationale` (why).
- `discussions`: topics that were debated. `topic` plus `points` (the considerations raised). Open / unresolved discussions are valid.
- `attempts`: things that were tried. `action`, `result`, and a `succeeded` boolean. Partial success is `false` with the result text describing the partial outcome.
- `requests`: structured summaries of user submissions. `intent` (what the user wants), optional `target` (file / module / feature), and a one-line `summary`.
# Quality bar
- Drop one-off chit-chat, shallow questions, and turn-by-turn progress noise. Keep entries with long-term reference value.
- Do not duplicate content already captured by static project docs (AGENTS.md, plan documents) — those are not "what happened in this slice".
- Prefer concise, fact-shaped strings. Do not pad rationale or summary fields.
When you have produced the JSON, call `write_extracted` and end the turn. No follow-up text.
"#;