mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-03-26 14:01:14 -07:00
Introduces a 'create_new_topic' tool to organize agent work into logical chapters in the UI. Key changes: - Added TopicManager singleton to track active session phase. - Updated Scheduler to prioritize topic markers at the start of batches. - Injected active topic context into prompt footers for model alignment. - Removed 'Explain Before Acting' mandate in favor of semantic headers. - Added behavioral eval to ensure model compliance with grouping.
2.3 KiB
2.3 KiB
Plan: Linear Semantic Topic Grouping (Chapters)
Implement a semantic topic grouping system to organize tool calls into sequential "Chapters" in the UI using a dedicated tool and prompt feedback.
1. Core Component: Topic Management
Create a lightweight TopicManager to maintain the session's current semantic
state.
- Location:
packages/core/src/tools/topicTool.ts - Role: A singleton that stores the
activeTopicTitle. - Logic:
setTopic(title: string): Updates the current title.getTopic(): Returns the current title (defaults toundefined).
2. The create_new_topic Tool
A nearly No-OP tool that acts as the trigger for UI "Chapter" breaks.
- Name:
create_new_topic - Parameters:
title: string(e.g., "Researching Codebase", "Implementing Fix"). - Execution Logic:
- Calls
TopicManager.setTopic(title). - Returns a simple confirmation message:
Topic changed to: "${title}".
- Calls
- UI Impact: The UI detects this tool name in the stream and renders a visual divider/header.
3. Scheduler Ordering (Turn-Ahead Alignment)
Ensure the "Chapter Header" appears before actions in a single turn.
- Location:
packages/core/src/scheduler/scheduler.ts - Change: In
_startBatch, sort incomingtoolCalls. Movecreate_new_topicto index0. - Reason: Correct UI rendering order for simultaneous calls.
4. Context Reinjection (Loop Feedback)
Keep the model aware of its current "Chapter" to prevent redundant calls.
- Location:
packages/core/src/prompts/promptProvider.ts - Change: Append the current topic to the system prompt footer (e.g.,
[Active Topic: Researching Auth Flow]). - Instruction: Add mandate: "If the current active topic no longer
describes your current phase of work, use
create_new_topicto start a new chapter."
5. System Prompt Refinement
Update packages/core/src/prompts/snippets.ts with guidance.
- Guidance: "Use
create_new_topicto organize your work into logical chapters. Call it when transitioning between major steps (e.g., Research -> Strategy -> Implementation)." - Constraint: Forward-only semantic marker.
6. Verification & Evaluation
- Behavioral Eval: Create
evals/topic_grouping.eval.ts. - Validation: Run
npm run preflightto ensure monorepo-wide stability.