# kminh-wow/ondeviceai architecture

> Architecture diagram of the GitHub repository kminh-wow/ondeviceai, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-11). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/kminh-wow/ondeviceai
- Repository: https://github.com/kminh-wow/ondeviceai

## Overview

This repository is an experiment harness for comparing quantized Qwen3 models on multi-step tool-use tasks, with a separate BFCL multi-turn validation track. The main workflow generates gold tasks, runs an agent against a model server and deterministic mock world, then scores and analyzes trajectories; human audit supports score validation. BFCL runs the same broad evaluation pattern against its stateful virtual APIs. The graph follows documented capabilities and indexed or excerpted references; unsampled runtime details are not inferred.

Main entry points: [`bfcl_runner.py`](https://github.com/kminh-wow/ondeviceai/blob/main/bfcl_runner.py) (BFCL runner), [`run_experiment.py`](https://github.com/kminh-wow/ondeviceai/blob/main/run_experiment.py) (Experiment runner), [`tasks.py`](https://github.com/kminh-wow/ondeviceai/blob/main/tasks.py) (Task generation), [`evaluate.py`](https://github.com/kminh-wow/ondeviceai/blob/main/evaluate.py) (Trajectory scoring)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experiment["Core experiment"]
  node_tasks["Task generation<br/>[tasks.py]"]
  node_runner["Experiment runner<br/>[run_experiment.py]"]
  node_agent["Tool-calling agent<br/>[agent.py]"]
end

subgraph group_world["Mock task world"]
  node_world["Mock tool world<br/>[tools_env.py]"]
end

subgraph group_metrics["Scoring and analysis"]
  node_evaluator["Trajectory scoring<br/>[evaluate.py]"]
  node_analysis["Experiment analysis<br/>[analyze.py]"]
  node_audit["Human score audit<br/>[audit.py]"]
end

subgraph group_bfcl["BFCL validation"]
  node_bfclrunner["BFCL runner<br/>[bfcl_runner.py]"]
  node_bfclanalysis["BFCL analysis<br/>[bfcl_analyze.py]"]
  node_bfcldata["BFCL scenarios and tool docs"]
end

subgraph group_apis["Virtual APIs"]
  node_longcontext["API scenario data<br/>[long_context.py]"]
  node_filesystem["File system API"]
  node_travelapi["Travel booking API<br/>[travel_booking.py]"]
  node_vehicleapi["Vehicle control API<br/>[vehicle_control.py]"]
  node_tradingapi["Trading API<br/>[trading_bot.py]"]
  node_otherapis["Other virtual APIs"]
end

node_user(("Experiment operator"))
node_modelserver["llama.cpp model server"]

node_user -->|"generates tasks"| node_tasks
node_user -->|"runs experiments"| node_runner
node_user -->|"analyzes results"| node_analysis
node_user -->|"audits scores"| node_audit
node_user -->|"runs validation"| node_bfclrunner
node_tasks -->|"builds oracle"| node_world
node_runner -->|"loads tasks"| node_tasks
node_runner -->|"runs agent"| node_agent
node_runner -->|"scores runs"| node_evaluator
node_runner -->|"queries model"| node_modelserver
node_agent -->|"requests completions"| node_modelserver
node_agent -->|"executes tools"| node_world
node_evaluator -->|"uses tool specs"| node_world
node_analysis -->|"rescores runs"| node_evaluator
node_analysis -->|"rebuilds task map"| node_tasks
node_audit -->|"checks scores"| node_evaluator
node_audit -->|"loads tasks"| node_tasks
node_bfclrunner -->|"queries model"| node_modelserver
node_bfclrunner -->|"loads scenarios and docs"| node_bfcldata
node_bfclrunner -->|"instantiates API"| node_filesystem
node_bfclrunner -->|"instantiates API"| node_travelapi
node_bfclrunner -->|"instantiates API"| node_vehicleapi
node_bfclrunner -->|"instantiates API"| node_tradingapi
node_bfclrunner -->|"uses virtual APIs"| node_otherapis
node_filesystem -->|"imports scenario data"| node_longcontext
node_travelapi -->|"imports scenario data"| node_longcontext
node_vehicleapi -->|"imports scenario data"| node_longcontext
node_tradingapi -->|"imports scenario data"| node_longcontext
node_bfclrunner -.->|"analyzes results"| node_bfclanalysis

click node_tasks "https://github.com/kminh-wow/ondeviceai/blob/main/tasks.py"
click node_runner "https://github.com/kminh-wow/ondeviceai/blob/main/run_experiment.py"
click node_agent "https://github.com/kminh-wow/ondeviceai/blob/main/agent.py"
click node_world "https://github.com/kminh-wow/ondeviceai/blob/main/tools_env.py"
click node_evaluator "https://github.com/kminh-wow/ondeviceai/blob/main/evaluate.py"
click node_analysis "https://github.com/kminh-wow/ondeviceai/blob/main/analyze.py"
click node_audit "https://github.com/kminh-wow/ondeviceai/blob/main/audit.py"
click node_bfclrunner "https://github.com/kminh-wow/ondeviceai/blob/main/bfcl_runner.py"
click node_bfclanalysis "https://github.com/kminh-wow/ondeviceai/blob/main/bfcl_analyze.py"
click node_bfcldata "https://github.com/kminh-wow/ondeviceai/tree/main/bfcl/data"
click node_longcontext "https://github.com/kminh-wow/ondeviceai/blob/main/bfcl/func_source_code/long_context.py"
click node_filesystem "https://github.com/kminh-wow/ondeviceai/blob/main/bfcl/func_source_code/gorilla_file_system.py"
click node_travelapi "https://github.com/kminh-wow/ondeviceai/blob/main/bfcl/func_source_code/travel_booking.py"
click node_vehicleapi "https://github.com/kminh-wow/ondeviceai/blob/main/bfcl/func_source_code/vehicle_control.py"
click node_tradingapi "https://github.com/kminh-wow/ondeviceai/blob/main/bfcl/func_source_code/trading_bot.py"
click node_otherapis "https://github.com/kminh-wow/ondeviceai/tree/main/bfcl/func_source_code"

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_tasks,node_runner,node_agent toneBlue
class node_world toneAmber
class node_evaluator,node_analysis,node_audit,node_modelserver toneMint
class node_bfclrunner,node_bfclanalysis,node_bfcldata toneRose
class node_longcontext,node_filesystem,node_travelapi,node_vehicleapi,node_tradingapi,node_otherapis,node_user toneIndigo
```

## Components

### Core experiment

- [Task generation](https://github.com/kminh-wow/ondeviceai/blob/main/tasks.py): `tasks.py`
- [Experiment runner](https://github.com/kminh-wow/ondeviceai/blob/main/run_experiment.py): `run_experiment.py`
- [Tool-calling agent](https://github.com/kminh-wow/ondeviceai/blob/main/agent.py): `agent.py`

### Mock task world

- [Mock tool world](https://github.com/kminh-wow/ondeviceai/blob/main/tools_env.py): `tools_env.py`

### Scoring and analysis

- [Trajectory scoring](https://github.com/kminh-wow/ondeviceai/blob/main/evaluate.py): `evaluate.py`
- [Experiment analysis](https://github.com/kminh-wow/ondeviceai/blob/main/analyze.py): `analyze.py`
- [Human score audit](https://github.com/kminh-wow/ondeviceai/blob/main/audit.py): `audit.py`

### BFCL validation

- [BFCL runner](https://github.com/kminh-wow/ondeviceai/blob/main/bfcl_runner.py): `bfcl_runner.py`
- [BFCL analysis](https://github.com/kminh-wow/ondeviceai/blob/main/bfcl_analyze.py): `bfcl_analyze.py`
- [BFCL scenarios and tool docs](https://github.com/kminh-wow/ondeviceai/tree/main/bfcl/data): `bfcl/data`

### Virtual APIs

- [API scenario data](https://github.com/kminh-wow/ondeviceai/blob/main/bfcl/func_source_code/long_context.py): `bfcl/func_source_code/long_context.py`
- [File system API](https://github.com/kminh-wow/ondeviceai/blob/main/bfcl/func_source_code/gorilla_file_system.py): `bfcl/func_source_code/gorilla_file_system.py`
- [Travel booking API](https://github.com/kminh-wow/ondeviceai/blob/main/bfcl/func_source_code/travel_booking.py): `bfcl/func_source_code/travel_booking.py`
- [Vehicle control API](https://github.com/kminh-wow/ondeviceai/blob/main/bfcl/func_source_code/vehicle_control.py): `bfcl/func_source_code/vehicle_control.py`
- [Trading API](https://github.com/kminh-wow/ondeviceai/blob/main/bfcl/func_source_code/trading_bot.py): `bfcl/func_source_code/trading_bot.py`
- [Other virtual APIs](https://github.com/kminh-wow/ondeviceai/tree/main/bfcl/func_source_code): `bfcl/func_source_code`

### Other components

- **Experiment operator**
- **llama.cpp model server**

## Connections

- Experiment operator → Task generation: generates tasks (evidence: `README.md`)
- Experiment operator → Experiment runner: runs experiments (evidence: `README.md`)
- Experiment operator → Experiment analysis: analyzes results (evidence: `README.md`)
- Experiment operator → Human score audit: audits scores (evidence: `README.md`)
- Experiment operator → BFCL runner: runs validation (evidence: `README.md`)
- Task generation → Mock tool world: builds oracle (evidence: `tasks.py`)
- Experiment runner → Task generation: loads tasks (evidence: `run_experiment.py`)
- Experiment runner → Tool-calling agent: runs agent (evidence: `run_experiment.py`)
- Experiment runner → Trajectory scoring: scores runs (evidence: `run_experiment.py`)
- Experiment runner → llama.cpp model server: queries model (evidence: `README.md`)
- Tool-calling agent → llama.cpp model server: requests completions (evidence: `agent.py`)
- Tool-calling agent → Mock tool world: executes tools (evidence: `agent.py`)
- Trajectory scoring → Mock tool world: uses tool specs (evidence: `evaluate.py`)
- Experiment analysis → Trajectory scoring: rescores runs (evidence: `analyze.py`)
- Experiment analysis → Task generation: rebuilds task map (evidence: `analyze.py`)
- Human score audit → Trajectory scoring: checks scores (evidence: `audit.py`)
- Human score audit → Task generation: loads tasks (evidence: `audit.py`)
- BFCL runner → llama.cpp model server: queries model (evidence: `bfcl_runner.py`)
- BFCL runner → BFCL scenarios and tool docs: loads scenarios and docs (evidence: `bfcl_runner.py`)
- BFCL runner → File system API: instantiates API (evidence: `README.md`)
- BFCL runner → Travel booking API: instantiates API (evidence: `README.md`)
- BFCL runner → Vehicle control API: instantiates API (evidence: `README.md`)
- BFCL runner → Trading API: instantiates API (evidence: `README.md`)
- BFCL runner → Other virtual APIs: uses virtual APIs (evidence: `README.md`)
- File system API → API scenario data: imports scenario data (evidence: `bfcl/func_source_code/gorilla_file_system.py`)
- Travel booking API → API scenario data: imports scenario data (evidence: `bfcl/func_source_code/travel_booking.py`)
- Vehicle control API → API scenario data: imports scenario data (evidence: `bfcl/func_source_code/vehicle_control.py`)
- Trading API → API scenario data: imports scenario data (evidence: `bfcl/func_source_code/trading_bot.py`)
- BFCL runner → BFCL analysis: analyzes results
