# bird-bench/bird-interact architecture

> Architecture diagram of the GitHub repository bird-bench/bird-interact, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-24). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/bird-bench/bird-interact
- Repository: https://github.com/bird-bench/bird-interact

## Overview

#### Purpose and variants
BIRD-INTERACT is an interactive text-to-SQL benchmark: agents resolve ambiguous requests through dialogue, execute CRUD-capable SQL against task databases, and are scored with executable test cases. The repository contains legacy/reference implementations for fixed conversational interaction, dynamic agentic interaction, SQLite mini variants, evaluation infrastructure, and a newer modular ADK implementation.

#### Primary entry points
- Recommended implementation: `BIRD-Interact-ADK/orchestrator/runner.py`, with service startup in `BIRD-Interact-ADK/scripts/start_services.sh`.
- Dynamic a-Interact batch runs: `bird_interact_agent/batch_run_bird_interact/main.py`; experiment driver: `bird_interact_agent/experiments/eval_react_bird_interact.py`.
- Fixed c-Interact pipeline: `bird_interact_conv/pipeline/run_gpt.sh`, orchestrating staged inference under `bird_interact_conv/code/`.
- Official scoring: `evaluation/run/run_eval.sh` and `evaluation/src/eval_bird_interact.py`.

#### ADK microservice architecture
The ADK implementation separates three replaceable Python services:
- **System agent service** hosts the Google ADK runtime, agent definition, callbacks, and SQL-facing tools: `BIRD-Interact-ADK/system_agent/server.py`, `BIRD-Interact-ADK/system_agent/agent.py`, `BIRD-Interact-ADK/system_agent/tools.py`.
- **User-simulator service** turns ambiguous task data and dialogue into simulated user responses, including SQL-aware parsing: `BIRD-Interact-ADK/user_simulator/server.py`, `BIRD-Interact-ADK/user_simulator/prompts.py`, `BIRD-Interact-ADK/user_simulator/sql_parser.py`.
- **Database-environment service** isolates database access behind its own server: `BIRD-Interact-ADK/db_environment/server.py`.
- The orchestration layer selects a-Interact versus c-Interact execution, runs tasks (including parallel work), and emits reports: `BIRD-Interact-ADK/orchestrator/runner.py`, `BIRD-Interact-ADK/orchestrator/ainteract.py`, `BIRD-Interact-ADK/orchestrator/cinteract.py`.

#### Interaction and SQL execution flow
A task supplies a selected database, ambiguous query, ambiguity annotations, contextual knowledge, lifecycle SQL, and hidden solution/test data. In a-Interact, the model decides when to ask the simulator, inspect/act on the database, and finalize SQL. In c-Interact, dialogue follows a predetermined multi-stage flow before SQL wrap-up. SQL parsing is a critical boundary between natural-language interactions and executable statements. Agent/environment abstractions implement this loop in `bird_interact_agent/src/envs/ic_env.py`, `bird_interact_agent/src/envs/bird_interact_env/sql_env.py`, and `bird_interact_agent/src/envs/user_simulator/us_env_bird_interact.py`.

#### Model-provider boundary
LLM calls are abstracted from interaction logic. The legacy agent supports provider/API implementations and CLI/human alternatives through `bird_interact_agent/src/llm_utils/llm_provider.py`, `bird_interact_agent/src/llm_utils/llm_agent.py`, and `bird_interact_agent/src/llm_utils/api_util.py`. The ADK version uses LiteLLM-compatible providers via `BIRD-Interact-ADK/shared/llm.py`, allowing agent models to be swapped without changing the orchestrator or services.

#### Evaluation and database infrastructure
Docker provisions PostgreSQL databases for Lite and Full datasets plus an evaluation container: `env/docker-compose.yml`, `env/Dockerfile.postgresql`, `env/Dockerfile.bird_interact_eval`. Evaluation applies preprocessing/cleanup and validates predicted SQL against executable test cases; PostgreSQL is primary, while adapters also support MySQL, MSSQL, and Oracle: `evaluation/src/eval_bird_interact_batch.py`, `evaluation/src/postgresql_utils.py`, `evaluation/src/wrapper_evaluation_postgresql.py`.

#### Related distributions
`mini_interact/knowledge_based/` mirrors the benchmark architecture for SQLite-oriented Mini-Interact. `usersim-guard/` is a separate user-simulator guard pipeline, including LLM-as-judge behavior: `usersim-guard/run_pipeline.py`, `usersim-guard/user_simulator/pipeline.py`, `usersim-guard/user_simulator/llm_as_judge.py`.

Main entry points: [`BIRD-Interact-ADK/system_agent/server.py`](https://github.com/bird-bench/bird-interact/blob/main/BIRD-Interact-ADK/system_agent/server.py) (System agent service), [`BIRD-Interact-ADK/user_simulator/server.py`](https://github.com/bird-bench/bird-interact/blob/main/BIRD-Interact-ADK/user_simulator/server.py) (User simulator service), [`bird_interact_agent/src/envs/ic_env.py`](https://github.com/bird-bench/bird-interact/blob/main/bird_interact_agent/src/envs/ic_env.py) (Agent/environment loop), [`BIRD-Interact-ADK/db_environment/server.py`](https://github.com/bird-bench/bird-interact/blob/main/BIRD-Interact-ADK/db_environment/server.py) (Database environment service)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_adk["ADK implementation"]
  node_adk_start["Service startup<br/>shell launcher<br/>[start_services.sh]"]
  node_adk_runner["Task runner<br/>orchestrator<br/>[runner.py]"]
  node_adk_ainteract["a-Interact flow<br/>agentic interaction<br/>[ainteract.py]"]
  node_adk_cinteract["c-Interact flow<br/>fixed interaction<br/>[cinteract.py]"]
  node_system_agent{{"System agent service<br/>ADK service<br/>[server.py]"}}
  node_user_simulator{{"User simulator service<br/>simulation service<br/>[server.py]"}}
  node_db_service[("Database environment service<br/>database service<br/>[server.py]")]
  node_adk_llm["LiteLLM provider layer<br/>model adapter<br/>[llm.py]"]
end

subgraph group_legacy["Legacy interaction"]
  node_dynamic_batch["Dynamic batch runner<br/>batch entry point<br/>[main.py]"]
  node_dynamic_experiment["Dynamic experiment driver<br/>experiment runner"]
  node_legacy_env["Agent/environment loop<br/>interaction environment<br/>[ic_env.py]"]
  node_legacy_sql_env[("SQL environment<br/>database adapter<br/>[sql_env.py]")]
  node_legacy_user_env["Legacy user simulator<br/>simulation environment"]
  node_legacy_llm["Legacy LLM abstraction<br/>provider abstraction<br/>[llm_provider.py]"]
  node_fixed_pipeline["Fixed c-Interact pipeline<br/>staged pipeline<br/>[run_gpt.sh]"]
end

subgraph group_evaluation["Evaluation infrastructure"]
  node_eval_entry["Official evaluation<br/>scoring entry point<br/>[run_eval.sh]"]
  node_eval_engine["SQL validation engine<br/>evaluator"]
  node_postgres[("Dataset PostgreSQL<br/>database infrastructure<br/>[docker-compose.yml]")]
end

subgraph group_related["Related distributions"]
  node_mini_interact["Mini-Interact<br/>SQLite distribution"]
  node_usersim_guard["User-simulator guard<br/>judge pipeline<br/>[run_pipeline.py]"]
end

node_adk_start -->|"starts"| node_system_agent
node_adk_start -->|"starts"| node_user_simulator
node_adk_start -->|"starts"| node_db_service
node_adk_runner -->|"selects"| node_adk_ainteract
node_adk_runner -->|"selects"| node_adk_cinteract
node_adk_ainteract -->|"runs agent"| node_system_agent
node_adk_ainteract -->|"asks questions"| node_user_simulator
node_adk_cinteract -->|"runs SQL wrap-up"| node_system_agent
node_adk_cinteract -->|"uses staged dialogue"| node_user_simulator
node_system_agent -->|"SQL tools"| node_db_service
node_system_agent -->|"model calls"| node_adk_llm
node_user_simulator -->|"SQL-aware parsing"| node_db_service
node_dynamic_batch -->|"runs tasks"| node_legacy_env
node_dynamic_experiment -->|"drives"| node_dynamic_batch
node_legacy_env -->|"database actions"| node_legacy_sql_env
node_legacy_env -->|"dialogue turns"| node_legacy_user_env
node_legacy_env -->|"model calls"| node_legacy_llm
node_fixed_pipeline -->|"staged inference SQL"| node_legacy_sql_env
node_eval_entry -->|"invokes"| node_eval_engine
node_eval_engine -->|"executes test cases"| node_postgres
node_legacy_sql_env -.->|"task databases"| node_postgres
node_db_service -.->|"task databases"| node_postgres
node_usersim_guard -.->|"related guard behavior"| node_user_simulator

click node_adk_start "https://github.com/bird-bench/bird-interact/blob/main/BIRD-Interact-ADK/scripts/start_services.sh"
click node_adk_runner "https://github.com/bird-bench/bird-interact/blob/main/BIRD-Interact-ADK/orchestrator/runner.py"
click node_adk_ainteract "https://github.com/bird-bench/bird-interact/blob/main/BIRD-Interact-ADK/orchestrator/ainteract.py"
click node_adk_cinteract "https://github.com/bird-bench/bird-interact/blob/main/BIRD-Interact-ADK/orchestrator/cinteract.py"
click node_system_agent "https://github.com/bird-bench/bird-interact/blob/main/BIRD-Interact-ADK/system_agent/server.py"
click node_user_simulator "https://github.com/bird-bench/bird-interact/blob/main/BIRD-Interact-ADK/user_simulator/server.py"
click node_db_service "https://github.com/bird-bench/bird-interact/blob/main/BIRD-Interact-ADK/db_environment/server.py"
click node_adk_llm "https://github.com/bird-bench/bird-interact/blob/main/BIRD-Interact-ADK/shared/llm.py"
click node_dynamic_batch "https://github.com/bird-bench/bird-interact/blob/main/bird_interact_agent/batch_run_bird_interact/main.py"
click node_dynamic_experiment "https://github.com/bird-bench/bird-interact/blob/main/bird_interact_agent/experiments/eval_react_bird_interact.py"
click node_legacy_env "https://github.com/bird-bench/bird-interact/blob/main/bird_interact_agent/src/envs/ic_env.py"
click node_legacy_sql_env "https://github.com/bird-bench/bird-interact/blob/main/bird_interact_agent/src/envs/bird_interact_env/sql_env.py"
click node_legacy_user_env "https://github.com/bird-bench/bird-interact/blob/main/bird_interact_agent/src/envs/user_simulator/us_env_bird_interact.py"
click node_legacy_llm "https://github.com/bird-bench/bird-interact/blob/main/bird_interact_agent/src/llm_utils/llm_provider.py"
click node_fixed_pipeline "https://github.com/bird-bench/bird-interact/blob/main/bird_interact_conv/pipeline/run_gpt.sh"
click node_eval_entry "https://github.com/bird-bench/bird-interact/blob/main/evaluation/run/run_eval.sh"
click node_eval_engine "https://github.com/bird-bench/bird-interact/blob/main/evaluation/src/eval_bird_interact.py"
click node_postgres "https://github.com/bird-bench/bird-interact/blob/main/env/docker-compose.yml"
click node_usersim_guard "https://github.com/bird-bench/bird-interact/blob/main/usersim-guard/run_pipeline.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_adk_start,node_adk_runner,node_adk_ainteract,node_adk_cinteract,node_system_agent,node_user_simulator,node_db_service,node_adk_llm toneBlue
class node_dynamic_batch,node_dynamic_experiment,node_legacy_env,node_legacy_sql_env,node_legacy_user_env,node_legacy_llm,node_fixed_pipeline toneAmber
class node_eval_entry,node_eval_engine,node_postgres toneMint
class node_mini_interact,node_usersim_guard toneRose
```

## Components

### ADK implementation

Recommended modular runtime.

- [Service startup](https://github.com/bird-bench/bird-interact/blob/main/BIRD-Interact-ADK/scripts/start_services.sh): shell launcher · Starts the ADK service set. · `BIRD-Interact-ADK/scripts/start_services.sh`
- [Task runner](https://github.com/bird-bench/bird-interact/blob/main/BIRD-Interact-ADK/orchestrator/runner.py): orchestrator · Selects interaction mode, parallelizes tasks, and writes reports. · `BIRD-Interact-ADK/orchestrator/runner.py`
- [a-Interact flow](https://github.com/bird-bench/bird-interact/blob/main/BIRD-Interact-ADK/orchestrator/ainteract.py): agentic interaction · Lets the model decide when to ask, inspect, act, and finalize. · `BIRD-Interact-ADK/orchestrator/ainteract.py`
- [c-Interact flow](https://github.com/bird-bench/bird-interact/blob/main/BIRD-Interact-ADK/orchestrator/cinteract.py): fixed interaction · Runs the predetermined dialogue stages before SQL wrap-up. · `BIRD-Interact-ADK/orchestrator/cinteract.py`
- [System agent service](https://github.com/bird-bench/bird-interact/blob/main/BIRD-Interact-ADK/system_agent/server.py): ADK service · Hosts ADK agent runtime, callbacks, and SQL tools. · `BIRD-Interact-ADK/system_agent/server.py`
- [User simulator service](https://github.com/bird-bench/bird-interact/blob/main/BIRD-Interact-ADK/user_simulator/server.py): simulation service · Produces SQL-aware simulated user responses. · `BIRD-Interact-ADK/user_simulator/server.py`
- [Database environment service](https://github.com/bird-bench/bird-interact/blob/main/BIRD-Interact-ADK/db_environment/server.py): database service · Isolates task database access behind a server boundary. · `BIRD-Interact-ADK/db_environment/server.py`
- [LiteLLM provider layer](https://github.com/bird-bench/bird-interact/blob/main/BIRD-Interact-ADK/shared/llm.py): model adapter · Makes ADK agent models replaceable. · `BIRD-Interact-ADK/shared/llm.py`

### Legacy interaction

Reference dynamic and fixed pipelines.

- [Dynamic batch runner](https://github.com/bird-bench/bird-interact/blob/main/bird_interact_agent/batch_run_bird_interact/main.py): batch entry point · `bird_interact_agent/batch_run_bird_interact/main.py`
- [Dynamic experiment driver](https://github.com/bird-bench/bird-interact/blob/main/bird_interact_agent/experiments/eval_react_bird_interact.py): experiment runner · `bird_interact_agent/experiments/eval_react_bird_interact.py`
- [Agent/environment loop](https://github.com/bird-bench/bird-interact/blob/main/bird_interact_agent/src/envs/ic_env.py): interaction environment · Coordinates agent actions, database state, and user simulation. · `bird_interact_agent/src/envs/ic_env.py`
- [SQL environment](https://github.com/bird-bench/bird-interact/blob/main/bird_interact_agent/src/envs/bird_interact_env/sql_env.py): database adapter · Executes agent database actions. · `bird_interact_agent/src/envs/bird_interact_env/sql_env.py`
- [Legacy user simulator](https://github.com/bird-bench/bird-interact/blob/main/bird_interact_agent/src/envs/user_simulator/us_env_bird_interact.py): simulation environment · `bird_interact_agent/src/envs/user_simulator/us_env_bird_interact.py`
- [Legacy LLM abstraction](https://github.com/bird-bench/bird-interact/blob/main/bird_interact_agent/src/llm_utils/llm_provider.py): provider abstraction · Supports API providers plus CLI and human alternatives. · `bird_interact_agent/src/llm_utils/llm_provider.py`
- [Fixed c-Interact pipeline](https://github.com/bird-bench/bird-interact/blob/main/bird_interact_conv/pipeline/run_gpt.sh): staged pipeline · Orchestrates fixed conversational inference stages. · `bird_interact_conv/pipeline/run_gpt.sh`

### Evaluation infrastructure

Executable database-backed scoring.

- [Official evaluation](https://github.com/bird-bench/bird-interact/blob/main/evaluation/run/run_eval.sh): scoring entry point · Runs executable benchmark scoring. · `evaluation/run/run_eval.sh`
- [SQL validation engine](https://github.com/bird-bench/bird-interact/blob/main/evaluation/src/eval_bird_interact.py): evaluator · Preprocesses predictions and validates them with executable test cases. · `evaluation/src/eval_bird_interact.py`
- [Dataset PostgreSQL](https://github.com/bird-bench/bird-interact/blob/main/env/docker-compose.yml): database infrastructure · Docker-provisioned Lite and Full task databases. · `env/docker-compose.yml`

### Related distributions

- **Mini-Interact**: SQLite distribution · SQLite-oriented mirror of the benchmark architecture.
- [User-simulator guard](https://github.com/bird-bench/bird-interact/blob/main/usersim-guard/run_pipeline.py): judge pipeline · Separate LLM-as-judge user-simulator guard pipeline. · `usersim-guard/run_pipeline.py`

## Connections

- Service startup → System agent service: starts
- Service startup → User simulator service: starts
- Service startup → Database environment service: starts
- Task runner → a-Interact flow: selects
- Task runner → c-Interact flow: selects
- a-Interact flow → System agent service: runs agent
- a-Interact flow → User simulator service: asks questions
- c-Interact flow → System agent service: runs SQL wrap-up
- c-Interact flow → User simulator service: uses staged dialogue
- System agent service → Database environment service: SQL tools
- System agent service → LiteLLM provider layer: model calls
- User simulator service → Database environment service: SQL-aware parsing
- Dynamic batch runner → Agent/environment loop: runs tasks
- Dynamic experiment driver → Dynamic batch runner: drives
- Agent/environment loop → SQL environment: database actions
- Agent/environment loop → Legacy user simulator: dialogue turns
- Agent/environment loop → Legacy LLM abstraction: model calls
- Fixed c-Interact pipeline → SQL environment: staged inference SQL
- Official evaluation → SQL validation engine: invokes
- SQL validation engine → Dataset PostgreSQL: executes test cases
- SQL environment → Dataset PostgreSQL: task databases
- Database environment service → Dataset PostgreSQL: task databases
- User-simulator guard → User simulator service: related guard behavior
