GO-STAR is built off of the DS-STAR self-improving agent that can generally solve and optimize problems rather than the original DS-STAR constraint of answering data science queries.
You can read about the original DS-STAR agent here: DS-STAR: A State-of-the-Art Versatile Data Science Agent. Paper
- Agentic Workflow: Implements a pipeline of specialized AI agents (Planner, Coder, Verifier, Router, Debugger, Finalyzer) that collaborate to solve and optimize problems.
- Reproducibility: Every step of the pipeline is saved, including prompts, generated code, execution results, and metadata. This allows for complete auditability and reproducibility of results.
- Interactive & Resume-able: Runs can be paused and resumed. The interactive mode allows for step-by-step execution.
- Code Editing & Debugging: Allows users to manually edit the generated code during a run and features an auto-debug agent to fix execution errors.
- Configuration-driven: Project settings, model parameters, evaluator, and run configurations are managed through a
config.yamlfile.
The GO-STAR pipeline is composed of several phases and agents:
- Iterative Planning & Execution:
- The
Plannercreates an initial plan to address the task. - The
Codergenerates Python code to execute the current step of the plan. - The code is executed, and the result is captured (either by the evaluator or the default runtime).
- An automatic
Debuggeragent attempts to fix any code that fails. - The
Verifierchecks if the result sufficiently aligns with the goals. - The
Routerdecides what to do next: either finalize the plan or add a new step for refinement. - This loop continues until the plan is deemed sufficient or the maximum number of refinement rounds is reached.
- The
- Finalization: The
Finalyzeragent takes the final code and results and formats them into a clean, specified output format (e.g., JSON).
All artifacts for each run are stored in the runs/ directory, organized by run_id.
GO-STAR uses an evaluator to score candidate solutions and decide when to stop refining. The evaluator can optionally execute the generated code itself and return structured JSON metrics, which the Verifier uses to judge progress against your goals.
Key config options:
query: the task description (required in config YAML).problem_context: extra constraints and output format requirements.evaluator: import path or file path to the evaluator class.evaluator_kwargs: constructor args for the evaluator.evaluator_runs_code: if true, evaluator executes code and provides stdout/metrics.evaluator_python: optional Python executable for evaluator-run code.
Example (program synthesis):
query: "Write code that checks whether a list of integers is strictly increasing."
problem_context: |
Read a single line from stdin. Output strict JSON:
{"is_sorted_unique": true|false}
evaluator_runs_code: true
evaluator: "examples/program_synthesis/program_evaluator.py:ProgramSynthesisEvaluator"/
├─── src/ds_star/ # Package source (agent logic, CLI, prompts)
├─── config.yaml # Main configuration file
├─── examples/ # Runnable toy examples and evaluators
├─── tests/ # Test suite
├─── pyproject.toml # Project metadata and dependencies (uv format)
├─── uv.lock # Locked dependency versions for reproducibility
├─── .python-version # Python version specification for uv
└─── runs/ # Directory where all experiment runs and artifacts are stored
- Python 3.11+
- An API key for Google's Gemini models.
- uv package manager (recommended)
-
Clone the repository:
git clone <repository-url> cd DS-Star
-
Install uv (if not already installed):
curl -LsSf https://astral.sh/uv/install.sh | sh -
Install dependencies with uv:
uv sync
-
Set your API Key: The application requires a Gemini API key. You can set it as an environment variable:
export GEMINI_API_KEY='your-api-key'
Alternatively, you can add it to the
config.yamlfile. -
Customize
config.yaml: Create aconfig.yamlfile in the root of the project and customize the settings. See the "Configuration" section below for details.# config.yaml model_name: 'gemini-1.5-flash' max_refinement_rounds: 5 interactive: false # api_key: 'your-api-key' # Alternatively, place it here # Optional: Configure specific models for different agents agent_models: PLANNER: 'gpt-4' CODER: 'gemini-1.5-pro' VERIFIER: 'gemini-1.5-flash'
Define the task in your config YAML and run with --config.
Using uv:
uv run dsstar --config examples/program_synthesis/program_config.yamlIf a run was interrupted, you can resume it using its run_id.
uv run dsstar --resume <run_id>You can manually edit the last generated piece of code and re-run it. This is useful for manual debugging or tweaking the agent's logic.
uv run dsstar --edit-last --resume <run_id>This will open the last code file in your default text editor (nano, vim, etc.). After you save and close the editor, the script will re-execute the modified code.
To review each step before proceeding, use the interactive flag.
uv run dsstar --interactive --query "..."This project uses uv for fast and reliable dependency management. Here are some useful commands:
- Install dependencies:
uv sync - Add a new dependency:
uv add package-name - Remove a dependency:
uv remove package-name - Update dependencies:
uv sync --upgrade - Run a command in the virtual environment:
uv run python script.py - Show installed packages:
uv pip list
- Speed: uv is 10-100x faster than pip
- Reliability: Consistent dependency resolution with lock files
- No virtual environment activation needed: Use
uv runto execute commands directly - Better dependency resolution: Automatically resolves complex dependency conflicts
The following options are available in config.yaml and can be overridden by CLI arguments:
run_id(string): The ID of a run to resume.max_refinement_rounds(int): The maximum number of times the agent will try to refine its plan.api_key(string): Your Gemini API key.model_name(string): The Gemini model to use (e.g.,gemini-1.5-flash).interactive(bool): If true, waits for user input before executing each step.auto_debug(bool): If true, theDebuggeragent will automatically try to fix failing code.execution_timeout(int): Timeout in seconds for code execution.preserve_artifacts(bool): If true, all step artifacts are saved to therunsdirectory.agent_models(dict): A dictionary mapping agent names (e.g.,PLANNER,CODER) to specific model names. If not specified,model_nameis used.problem_context(string): Optional per-run context passed to every agent.verifier_goals(string): Optional goals used by the verifier.evaluator(string): Evaluator import path or file path (e.g.,examples/toy_demo/toy_evaluator.py:ToyEvaluator).evaluator_kwargs(dict): Keyword args passed to the evaluator constructor.evaluator_runs_code(bool): If true, the evaluator executes generated code and returns stdout + metrics.evaluator_python(string): Optional Python executable for evaluator-run code.
DS-STAR supports multiple AI model providers. Each provider requires specific environment variables to be configured:
Provider Identifier: Default provider (no prefix required)
Environment Variable:
export GEMINI_API_KEY='your-gemini-api-key'Model Examples:gemini-2.5-pro, gemini-2.0-flash
Provider Identifier: Models prefixed with gpt or o1
Environment Variable:
export OPENAI_API_KEY='your-openai-api-key'Model Examples: gpt-4, gpt-4-turbo, o1
Provider Identifier: Models prefixed with ollama/
Environment Variables:
export OLLAMA_API_KEY='your-ollama-api-key' # Optional
export OLLAMA_HOST='http://localhost:11434' # Optional, defaults to http://localhost:11434Model Examples: ollama/llama3, ollama/qwen3-coder
Contributions are welcome! Please feel free to submit a pull request or open an issue for any bugs or feature requests.
