# iquestlab/modularrsi architecture

> Architecture diagram of the GitHub repository iquestlab/modularrsi, 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/iquestlab/modularrsi
- Repository: https://github.com/iquestlab/modularrsi

## Overview

ModularRSI is a research system for improving agent harnesses from execution experience and evaluating whether improvements transfer. Its documented workflow samples benchmark-independent trajectories, contrasts successes and failures, evolves harness modules independently, filters candidates through validation gates, integrates cross-module changes, then freezes the resulting function library for downstream evaluation. The tree exposes the included harness modules, but not the evolution and evaluation orchestration; those stages are therefore represented as documented subsystems rather than inferred implementations.

Main entry points: [`generations/merged_active/gen_0/modules`](https://github.com/iquestlab/modularrsi/tree/main/generations/merged_active/gen_0/modules) (Frozen function library), [`generations/merged_active/gen_0/modules/agent_loop/baseline.py`](https://github.com/iquestlab/modularrsi/blob/main/generations/merged_active/gen_0/modules/agent_loop/baseline.py) (Agent loop), [`generations/merged_active/gen_0/modules/observation/baseline.py`](https://github.com/iquestlab/modularrsi/blob/main/generations/merged_active/gen_0/modules/observation/baseline.py) (Observation), [`generations/merged_active/gen_0/modules/tools/baseline.py`](https://github.com/iquestlab/modularrsi/blob/main/generations/merged_active/gen_0/modules/tools/baseline.py) (Tools)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_learning["Learning workflow"]
  node_trajectory_sampling["Trajectory sampling"]
  node_contrastive_analysis["Contrastive analysis"]
  node_module_evolution["Module-wise evolution"]
end

subgraph group_harness["Harness modules"]
  node_agent_loop["Agent loop<br/>[baseline.py]"]
  node_observation["Observation<br/>[baseline.py]"]
  node_tools["Tools<br/>[baseline.py]"]
  node_context_mgmt["Context management<br/>[baseline.py]"]
  node_completion_detection["Completion detection"]
end

subgraph group_validation["Validation and integration"]
  node_program_checks["Program checks"]
  node_diff_review["Diff review"]
  node_execution_validation["Execution validation"]
  node_cross_module_integration["Cross-module integration"]
end

subgraph group_evaluation["Evaluation"]
  node_frozen_library["Frozen function library"]
  node_downstream_tasks["Downstream evaluation"]
  node_unseen_domains["Transfer evaluation"]
end

node_researcher(("Researcher"))

node_researcher -->|"starts evolution"| node_trajectory_sampling
node_trajectory_sampling -->|"provides trajectories"| node_contrastive_analysis
node_contrastive_analysis -->|"guides changes"| node_module_evolution
node_module_evolution -->|"evolves module"| node_agent_loop
node_module_evolution -->|"evolves module"| node_observation
node_module_evolution -->|"evolves module"| node_tools
node_module_evolution -->|"evolves module"| node_context_mgmt
node_module_evolution -->|"evolves module"| node_completion_detection
node_module_evolution -->|"screens candidates"| node_program_checks
node_module_evolution -->|"screens candidates"| node_diff_review
node_module_evolution -->|"screens candidates"| node_execution_validation
node_program_checks -->|"permits integration"| node_cross_module_integration
node_diff_review -->|"permits integration"| node_cross_module_integration
node_execution_validation -->|"permits integration"| node_cross_module_integration
node_cross_module_integration -->|"produces library"| node_frozen_library
node_frozen_library -->|"evaluated on"| node_downstream_tasks
node_downstream_tasks -->|"measures transfer"| node_unseen_domains

click node_agent_loop "https://github.com/iquestlab/modularrsi/blob/main/generations/merged_active/gen_0/modules/agent_loop/baseline.py"
click node_observation "https://github.com/iquestlab/modularrsi/blob/main/generations/merged_active/gen_0/modules/observation/baseline.py"
click node_tools "https://github.com/iquestlab/modularrsi/blob/main/generations/merged_active/gen_0/modules/tools/baseline.py"
click node_context_mgmt "https://github.com/iquestlab/modularrsi/blob/main/generations/merged_active/gen_0/modules/context_mgmt/baseline.py"
click node_frozen_library "https://github.com/iquestlab/modularrsi/tree/main/generations/merged_active/gen_0/modules"

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_trajectory_sampling,node_contrastive_analysis,node_module_evolution toneBlue
class node_agent_loop,node_observation,node_tools,node_context_mgmt,node_completion_detection toneAmber
class node_program_checks,node_diff_review,node_execution_validation,node_cross_module_integration toneMint
class node_frozen_library,node_downstream_tasks,node_unseen_domains toneRose
class node_researcher toneIndigo
```

## Components

### Learning workflow

- **Trajectory sampling**
- **Contrastive analysis**
- **Module-wise evolution**

### Harness modules

- [Agent loop](https://github.com/iquestlab/modularrsi/blob/main/generations/merged_active/gen_0/modules/agent_loop/baseline.py): `generations/merged_active/gen_0/modules/agent_loop/baseline.py`
- [Observation](https://github.com/iquestlab/modularrsi/blob/main/generations/merged_active/gen_0/modules/observation/baseline.py): `generations/merged_active/gen_0/modules/observation/baseline.py`
- [Tools](https://github.com/iquestlab/modularrsi/blob/main/generations/merged_active/gen_0/modules/tools/baseline.py): `generations/merged_active/gen_0/modules/tools/baseline.py`
- [Context management](https://github.com/iquestlab/modularrsi/blob/main/generations/merged_active/gen_0/modules/context_mgmt/baseline.py): `generations/merged_active/gen_0/modules/context_mgmt/baseline.py`
- **Completion detection**

### Validation and integration

- **Program checks**
- **Diff review**
- **Execution validation**
- **Cross-module integration**

### Evaluation

- [Frozen function library](https://github.com/iquestlab/modularrsi/tree/main/generations/merged_active/gen_0/modules): `generations/merged_active/gen_0/modules`
- **Downstream evaluation**
- **Transfer evaluation**

### Other components

- **Researcher**

## Connections

- Researcher → Trajectory sampling: starts evolution (evidence: `README.md`)
- Trajectory sampling → Contrastive analysis: provides trajectories (evidence: `README.md`)
- Contrastive analysis → Module-wise evolution: guides changes (evidence: `README.md`)
- Module-wise evolution → Agent loop: evolves module (evidence: `README.md`)
- Module-wise evolution → Observation: evolves module (evidence: `README.md`)
- Module-wise evolution → Tools: evolves module (evidence: `README.md`)
- Module-wise evolution → Context management: evolves module (evidence: `README.md`)
- Module-wise evolution → Completion detection: evolves module (evidence: `README.md`)
- Module-wise evolution → Program checks: screens candidates (evidence: `README.md`)
- Module-wise evolution → Diff review: screens candidates (evidence: `README.md`)
- Module-wise evolution → Execution validation: screens candidates (evidence: `README.md`)
- Program checks → Cross-module integration: permits integration (evidence: `README.md`)
- Diff review → Cross-module integration: permits integration (evidence: `README.md`)
- Execution validation → Cross-module integration: permits integration (evidence: `README.md`)
- Cross-module integration → Frozen function library: produces library (evidence: `README.md`)
- Frozen function library → Downstream evaluation: evaluated on (evidence: `README.md`)
- Downstream evaluation → Transfer evaluation: measures transfer (evidence: `README.md`)
