How suraj-gameramp/scribe works
Purpose and Entry Points
SCRIBE is a reproducible harness for DABStep data-analysis tasks using a three-role, spec-conditioned agent workflow. The runtime entry point is src/run.ts; canonical behavior is selected through configs/scribe_main.yaml. A small end-to-end reproduction is orchestrated by scripts/repro.sh.
Run Configuration and Model Resolution
Run YAML config defines model/provider assignments, prompts, task split, and execution settings. src/config.ts loads the run configuration, while src/model_resolver.ts maps configured model names/providers to callable model clients. Canonical and baseline variants are preserved under configs/ and experiments/configs/, enabling planner/executor/provider comparisons.
Frozen Spec Planning
The first frontier-model role reads each task plus downloaded source context and produces a structured computation plan. That plan is injected into the executor context and intended to remain immutable during normal execution. Prompt contracts for baseline, grafted, iterative, and domain-knowledge variants reside in:
• src/prompts/dabstep_baseline.yaml
• src/prompts/dabstep_grafted.yaml
• src/prompts/dabstep_grafted_iterative.yaml
ReAct Execution and Python Boundary
A lower-cost executor model runs the main iterative agent/tool loop. It can inspect the frozen specification, reason over the task, and execute data analysis only through the controlled Python tool boundary:
• src/harness/tools/run_python.ts
• src/harness/services/python_repl.ts
• src/harness/tools/index.ts
The Python REPL is the operational boundary for loading task artifacts, calculating results, and producing the final answer; source documents and data are supplied under data/context/ after acquisition.
Backreview Escalation Path
When the executor identifies an interpretation conflict or ambiguity, it invokes the planner-facing escalation tool. This review path re-reads the task/source material and returns either confirmation or revised guidance, separating expensive specification reasoning from routine execution:
• src/harness/tools/ask_planner.ts
• src/harness/hooks/after_tool.ts
• src/run.ts
This is the primary control-flow branch beyond ordinary ReAct: initial spec → executor actions → optional review/escalation → continued execution.
Observability and Session Artifacts
The harness records token use, local task/run status, prompt cache behavior, and session traces, making each run inspectable and resumable at the experiment layer:
• src/harness/services/session_logger.ts
• src/harness/services/token_tracker.ts
• src/harness/services/local_tracker.ts
Committed outputs in results/, especially JSONL samples and reproduction manifests, are the durable evidence layer rather than application-facing output.
Dataset, Evaluation, and External Dependencies
Tasks and split definitions are versioned in data/target_tasks.jsonl and data/splits/. scripts/fetch_dabstep_data.py retrieves benchmark context/data; scripts/build_dataset.py and scripts/extract_specs.py support preparation; scripts/grade.py evaluates results against DABStep conventions. The system is Node/TypeScript plus Python, with model access configured through environment credentials for OpenRouter, Fireworks, and potentially Baseten; scripts/patch_pi_ai_env.cjs adapts the underlying AI SDK environment for provider compatibility.
Main entry points: run.ts Run entry point · target_tasks.jsonl Versioned tasks · after_tool.ts Post-tool review hook · dabstep_helper.py Downloaded context
Components 20
Agent Runtime
TypeScript orchestration and controlled execution.
- Run entry point · Selects canonical workflow and coordinates a run.
src/run.ts - Run configuration · Defines model roles, prompts, splits, and execution settings.
configs/scribe_main.yaml - Config loader
src/config.ts - Model resolver · Maps configured providers and model names to clients.
src/model_resolver.ts - Frozen spec planner · Creates the structured computation plan from task and source context.
- Planning prompt variants · Baseline, grafted, and iterative planner contracts.
src/prompts/dabstep_grafted.yaml - ReAct executor · Iterates over the task using the frozen plan and tools.
- Tool registry
src/harness/tools/index.ts - Python tool
src/harness/tools/run_python.ts - Python REPL · Loads artifacts, computes results, and produces answers.
src/harness/services/python_repl.ts - Planner escalation tool · Requests interpretation review for ambiguity or conflict.
src/harness/tools/ask_planner.ts - Post-tool review hook · Routes escalation and continued execution.
src/harness/hooks/after_tool.ts - Session observability · Records traces, token use, cache behavior, and local status.
src/harness/services/session_logger.ts
Dataset Pipeline
Task acquisition, preparation, and grading.
- Versioned tasks · DABStep tasks and split definitions.
data/target_tasks.jsonl - Downloaded context · Source documents and data supplied to planning and Python.
data/context/dabstep_helper.py - Data acquisition · Retrieves benchmark context and data.
scripts/fetch_dabstep_data.py - DABStep grader · Evaluates run results against benchmark conventions.
scripts/grade.py
Experiment Evidence
Inspectable run artifacts and variant configurations.
- Experiment variants · Canonical and comparison model/provider configurations.
experiments/configs/kimi_grafted.yaml - Results and manifests · Committed JSONL samples and reproduction evidence.
results/repro_pilot/run_manifest.json - End-to-end reproduction · Orchestrates a small reproduction run.
scripts/repro.sh
Connections 24
- Run configuration → Config loader: loaded by
- Config loader → Run entry point: run settings
- Run entry point → Model resolver: resolves role clients
- Experiment variants → Run configuration: comparison variants
- Versioned tasks → Run entry point: task and split
- Data acquisition → Downloaded context: downloads
- Downloaded context → Frozen spec planner: source material
- Versioned tasks → Frozen spec planner: task
- Planning prompt variants → Frozen spec planner: prompt contract
- Frozen spec planner → ReAct executor: immutable computation plan
- Versioned tasks → ReAct executor: task
- ReAct executor → Tool registry: tool calls
- Tool registry → Python tool: exposes
- Python tool → Python REPL: executes code
- Downloaded context → Python REPL: data and documents
- ReAct executor → Planner escalation tool: ambiguity or conflict
- Planner escalation tool → Post-tool review hook: review guidance
- Post-tool review hook → Frozen spec planner: re-reads specification
- Post-tool review hook → ReAct executor: continues execution
- Run entry point → Session observability: run telemetry
- Python REPL → Results and manifests: answers and artifacts
- Session observability → Results and manifests: traces and manifests
- Results and manifests → DABStep grader: evaluated by
- End-to-end reproduction → Run entry point: orchestrates