jp_lit_update_session_trace
Append research goal, scope, source plans, open questions, and next actions to the current session trace. Keep a log of investigation progress and decisions for Japanese literature research.
Instructions
現在の調査セッション全体に、調査目的・確認範囲・source 選択理由・未確認事項・次アクションを追記する。検索結果や選択候補そのものではなく、調査経過と判断の台帳を残すための tool
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| research_goal | No | ||
| scope_note | No | ||
| source_plans | No | ||
| open_questions | No | ||
| next_actions | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| session_id | Yes | ||
| updated_at | Yes | ||
| source_plan_count | Yes | ||
| open_question_count | Yes | ||
| next_action_count | Yes |
Implementation Reference
- Main handler function for jp_lit_update_session_trace. Parses input via Zod schema, calls sessionStore.updateTrace(), and returns structured content with session_id, updated_at, and counts of source_plans, open_questions, and next_actions.
export function createJpLitUpdateSessionTraceTool(sessionStore: SessionStore) { return async (input: unknown) => { const parsed = updateSessionTraceInputSchema.parse(input); const session = await sessionStore.updateTrace(parsed); const structuredContent: UpdateSessionTraceOutput = updateSessionTraceOutputSchema.parse({ session_id: session.session_id, updated_at: session.updated_at, source_plan_count: session.trace?.source_plans.length ?? 0, open_question_count: session.trace?.open_questions.length ?? 0, next_action_count: session.trace?.next_actions.length ?? 0 }); return { content: [ { type: "text" as const, text: JSON.stringify(structuredContent, null, 2) } ], structuredContent }; }; } - sessionStore.updateTrace() implementation. Reads the current session, merges trace fields (research_goal, scope_note overwrite; source_plans, open_questions, next_actions append with timestamps), and persists.
async updateTrace(input) { const session = await this.readCurrent(); const timestamp = nowIso(); const currentTrace = normalizeSessionTrace(session.trace); const nextTrace: SessionTrace = { ...currentTrace, ...(input.research_goal !== undefined ? { research_goal: input.research_goal } : {}), ...(input.scope_note !== undefined ? { scope_note: input.scope_note } : {}), source_plans: [ ...currentTrace.source_plans, ...(input.source_plans ?? []).map((entry) => ({ ...entry, created_at: timestamp })) ], open_questions: [ ...currentTrace.open_questions, ...(input.open_questions ?? []).map((entry) => ({ ...entry, created_at: timestamp })) ], next_actions: [ ...currentTrace.next_actions, ...(input.next_actions ?? []).map((entry) => ({ ...entry, created_at: timestamp })) ] }; const next: SessionDocument = { ...session, updated_at: timestamp, ...(hasSessionTraceContent(nextTrace) ? { trace: nextTrace } : {}) }; await persist(next); return next; },