Skip to content

feat: structured JSON output for brain and evaluate turns#13

Open
Savolent wants to merge 2 commits intovcarl:mainfrom
Savolent:feat/brain-structured-output
Open

feat: structured JSON output for brain and evaluate turns#13
Savolent wants to merge 2 commits intovcarl:mainfrom
Savolent:feat/brain-structured-output

Conversation

@Savolent
Copy link
Copy Markdown
Contributor

Summary

  • Adds --json-schema flag support to process-runner.ts so brain and evaluate turns receive constrained JSON output without markdown fences
  • Adds --fallback-model and --max-budget-usd pass-through flags for cost control
  • Inlines PLAN_SCHEMA and EVAL_SCHEMA JSON Schema constants into brain.ts so plan/evaluate calls produce valid, parseable output even from fast models
  • Fixes body turn role label: was incorrectly "brain", now correctly "body" in subagent-manager.ts
  • Exposes fallbackModel and maxBudgetUsd from SpawnSubagentConfig through to runTurn

Depends on

This branch stacks on top of #8 (configurable model selection). The diff against main includes commits from that PR. Merge after #8.

Test plan

  • Brain turn produces valid JSON plan without markdown fences
  • Evaluate turn produces valid JSON result
  • Fallback model flag is passed when configured
  • Body turn console output correctly labeled "body"

🤖 Generated with Claude Code

Savolent and others added 2 commits March 20, 2026 11:03
Brain functions no longer hardcode opus. Each brain role now defaults to a
cheaper model (plan/interrupt → sonnet, evaluate → haiku) and accepts an
optional model override via StateMachineConfig. Any non-Anthropic model
string routes to OpenRouter via HTTP, bypassing the Docker container.

- Add AnyModel type and callOpenRouter() to Claude service
- Add model override fields to StateMachineConfig, BrainContainerContext,
  PlanningServices, EvaluateServices, SpawnSubagentConfig
- Make dream and timeout-summarizer models configurable via env vars
  (DREAM_MODEL, TIMEOUT_SUMMARIZER_MODEL)
- Default step timeoutTicks raised from 10 to 30 ticks
- Body effort logic simplified: only body role gets normal effort

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add JSON schemas for plan and eval turns so the LLM is constrained to
produce valid JSON directly rather than wrapping in markdown. Eliminates
fence-stripping as the primary parse path (kept as fallback).

Also adds TurnConfig fields for fallbackModel, maxBudgetUsd, and
jsonSchema, wired through to claude CLI flags. Body turns now correctly
use role: "body" instead of role: "brain", enabling effort differentiation.

Depends on: feat/brain-model-flexibility (AnyModel, model override)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant