Skip to content

Commit 142dbfa

Browse files
hikejsclaude
andcommitted
feat(code): pre-analysis optimization and MiniMax compatibility
- Add LlmPlanner::pre_analyze() for single-call intent, goal, plan, and input optimization (reduces LLM round-trips) - Add ParallelStepResult structured JSON output for parallel plan steps - Fix OpenAI client: fallback to total_characters when total_tokens=0 (MiniMax API compatibility) - Fix delta_content extraction for reasoning models (handle empty deltas) - Add pre_analysis_system.md prompt for the new pre-analysis LLM call Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 76957dc commit 142dbfa

7 files changed

Lines changed: 350 additions & 51 deletions

File tree

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
1-
The following steps were executed in parallel:
2-
{results}
1+
The following plan steps completed in parallel. The results are provided as structured JSON in a USER message (not plain text) with this envelope:
32

4-
Continue with the next steps.
3+
```json
4+
{"type":"parallel_results","steps":[{"step_id":"...","step_number":1,"status":"completed","summary":"...","key_findings":[...],"error":null},...]}
5+
```
6+
7+
- `summary`: Brief description of what this step accomplished (in the user's language).
8+
- `key_findings`: Optional array of notable findings or outputs.
9+
- `error`: Present only when `status` is `"failed"`.
10+
11+
Use the structured step data above to continue planning and execution.
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
You are a pre-analysis assistant. Given a user message, perform all needed analysis in a single pass and return JSON. The JSON schema is:
2+
3+
{
4+
"intent": "GeneralPurpose|Plan|Explore|Verification|CodeReview",
5+
"requires_planning": true|false,
6+
"goal": {
7+
"description": "what the user ultimately wants to achieve",
8+
"success_criteria": ["criterion 1", "criterion 2"]
9+
},
10+
"execution_plan": {
11+
"complexity": "Simple|Medium|Complex|VeryComplex",
12+
"steps": [
13+
{
14+
"id": "step-1",
15+
"description": "what to do in this step",
16+
"tool": "bash|read|write|edit|grep|...",
17+
"dependencies": [],
18+
"success_criteria": "what counts as done for this step"
19+
}
20+
],
21+
"required_tools": ["tool_name"]
22+
},
23+
"optimized_input": "rewritten user message with ambiguous pronouns resolved, implied context made explicit, in the same language as the user message"
24+
}
25+
26+
Rules:
27+
- intent: "Plan" only if the user explicitly asks for planning/architecture/design. "Explore" only for read-only search tasks. "Verification" only for adversarial testing. "CodeReview" only for code quality analysis. Default to "GeneralPurpose".
28+
- requires_planning: true if the task has multiple steps, could benefit from structured reasoning, or the user asks for a plan. false for simple single-step tasks or read-only lookups.
29+
- complexity: Simple (<50 chars, 1 step), Medium (50-150 chars, 2-4 steps), Complex (150-300 chars, 5-8 steps), VeryComplex (>300 chars or many steps)
30+
- optimized_input: fix grammatical issues, resolve "it", "that", "the file" references, make implicit assumptions explicit. Keep the same meaning and language.
31+
- Respond with JSON only, no markdown fences or explanation.

0 commit comments

Comments
 (0)