Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

App ↔ research bridge

When to read this: You know either the production Chatty app or a research module, and need to see how they connect — memory, context window, agent loop, traces, sub-agents, and where SOTA work lands.

Parent frame: Paper → experiment → product.

Two views of the same system

flowchart TB
  subgraph app [Production Chatty — ships today]
    Loop[Agent loop<br/>llm_service + AgentFactory]
    Mem[Memory + skills<br/>memory_service]
    Ctx[Context window<br/>token_budget]
    Stream[StreamManager + ATIF export]
    Tools[~60 tools + MCP]
    SubAg[Sub-agents<br/>invoke_agent_tool]
    Settings[Settings models<br/>ModelConfig, Execution, Training]
  end

  subgraph research [Research domains — experiment → promote]
    M0[M0 Trace contract]
    M1[M1 ReAct fidelity]
    M2[M2 AFlow topology]
    M3[M3 GEPA prompts]
    M4[M4 ACE playbook]
  end

  Loop --> M1
  Loop --> M0
  Stream --> M0
  Mem --> M4
  Ctx --> M3
  Ctx --> M4
  Settings --> M3
  SubAg --> M2
  Tools --> M1
  Tools --> M2
  M0 --> M2
  M0 --> M3
  M0 --> M4

Read left → right to find which research module touches a production component. Read right → left to find where a promoted mechanism lands in the app.

Master mapping

App componentCode locationUser-facingResearch module(s)Promotion path
Agent loopservices/llm_service.rs, factories/agent_factory/Every chat turnM1 ReActAlready default; strategy variants TBD
LLM tools (~60)tools/Tool calls in chatM1 (action space), M2 (workflow nodes)Tools ship; topology search offline
Sub-agentsinvoke_agent_tool, list_agents_toolAgent delegationM2 AFlowWinning IR → FlowSettingsModel (planned)
Memory storeservices/memory_service.rs, memory.mv2remember / search_memoryM4 ACE, M6 Retrieval (Part B)Playbook on same store; scope TBD (AGE-47)
Web searchtools/search_web_tool.rs, tools/fetch_tool.rssearch_web / fetchM6 Retrieval (Part A)Provider chain + keyless tier as default if the eval shows it
Skillssave_skill_tool, SKILL.md files, [SKILL] prefixProcedures in contextM4 ACE (facts vs procedures split)Self-improving playbook vs manual skills
Context windowtoken_budget/ + GPUI footer barToken fill indicatorM3 cost, M4 prefix-cacheEstimation and compaction ship
Model preambleModelConfig.preambleSettings → model system promptM1 few-shot block, M3 GEPAUser-editable; GEPA optimizes offline
Trace / ATIFexporters/types.rs, StreamManagerTraining export toggleM0 TraceExport setting; full recorder TBD
Token pricingModelConfig.cost_per_million_*Cost display (sidebar)M3 GEPA, cost modelShips; optimizer accounting uses it
Code sandboxsandbox/, Monty bridgeCode execution settingM2 Monty code mode (future PythonRepr)Subprocess today; pause/resume deferred
Conversation historyConversationsStore, SQLiteChat threadsAll modules (trace input)Ships; compaction/summary future
Training exportTrainingSettingsModel, exportersOpt-in ATIF/JSONLM0 round-trip, M3/M4 offlineatif_auto_export setting

Full settings field map: settings integration map.


Agent loop & streaming

Production today

The ReAct-shaped loop runs in chatty-core: AgentFactory builds a rig-agent client, llm_service streams multi-turn tool calls, and GPUI’s StreamManager owns lifecycle (cancel, token usage, trace JSON) without duplicating response text.

ConcernDocKey files
Stream lifecyclestream-manager.mdchatty-gpui/.../stream_manager.rs
Entity wiringentity-communication.mdapp_controller/
Provider agentssystem-overview.mdfactories/agent_factory/

Research touchpoints

ModuleWhat changesStatus
M1Per-step ModuleId in trace; CoT/Act/SC variants for evalFidelity WIP
M0Hook + rig-tap capture → Trajectory; no hand-rolled loopNot started
M2Interpreter replaces flat loop with saved workflow IRNot started

Reserved: Strategy backoff rule (RESERVED.md) — affects loop termination only; loop body is not rewritten.


Memory, skills & playbook (M4)

Production today

Persistent memory uses memvid (memory.mv2). The agent gets remember and search_memory; skills are stored with a [SKILL] title prefix or as filesystem SKILL.md files. There is no automatic recall: the preamble tells the model to call search_memory itself. How that retrieval works, stage by stage, is in M6 Retrieval Part B.

ConcernDocKey files
Memory architectureagent-memory.mdmemory_service.rs, remember_tool.rs
Skill tools—save_skill_tool.rs, search_memory_tool.rs
Toggle—ExecutionSettingsModel.memory_enabled

Research touchpoints (ACE)

Paper conceptProduction analogueGap
Sectioned playbookFacts vs [SKILL] proceduresNo Reflector/Curator yet
Delta ops + deterministic applyManual remember / save_skillNo execution-feedback merge
Grow-and-refine / de-dupUnbounded memvid growthProduction eviction policy needed
Prompt-cache prefix stabilityStable skill ordering in search resultsByte-stable serialization TBD

Promotion: playbook runtime likely a setting (AGE-47 scope: global / per-model / per-conversation).


Context window & token budget

Production today

Before each LLM call, Chatty BPE-estimates preamble + tools + history against ModelConfig.max_context_window. The footer bar shows fill level; actual token counts patch in after the stream completes.

ConcernDocKey files
Token trackingtoken-tracking.mdtoken_budget/, GlobalTokenBudget
Response reserve—TokenTrackingSettings.response_reserve (default 4096)
Summarizationcontext-compaction.mdsummarizer.rs — summarize_oldest_half ships (/compact, desktop auto-summarise); only the secondary-model variant summarize_with_model is still a stub

Research touchpoints

ModuleConnection
M3 GEPAShorter optimized preambles affect context headroom; cost formula uses same token counts
M4 ACEPlaybook growth competes for context; paper assumes prompt-cache prefix reuse
M0RolloutBudget extends token accounting for train vs validation rollouts

Future product link: conversation compaction (the per-call guard in services/context_shaper.rs and the persisted summarize_oldest_half) is the natural place to apply ACE grow-and-refine eviction when playbook + history exceed pressure thresholds — the compaction ships; the playbook hook into it does not exist yet.


Model config & prompts (M1, M3)

Production today

Each model has a persisted ModelConfig: preamble (system prompt), temperature, context limit, per-million token pricing, multimodal flags.

#![allow(unused)]
fn main() {
// crates/chatty-core/src/settings/models/models_store.rs
pub struct ModelConfig {
    pub preamble: String,
    pub temperature: f32,
    pub max_context_window: Option<i32>,
    pub cost_per_million_input_tokens: Option<f64>,
    pub cost_per_million_output_tokens: Option<f64>,
    // ...
}
}

Research touchpoints

FieldM1M3
preambleFew-shot exemplar stable prefixGEPA optimization target
temperaturePaper regimesFixed during GEPA search
cost_per_million_*—Optimizer cost sheet (cost-model.md)

Promotion: GEPA output → preamble per model (setting); apply via AGE-45.


Traces, ATIF & training export (M0)

Production today

Conversations export to ATIF v1.6 (exporters/types.rs). StreamManager holds trace_json per stream. TrainingSettingsModel toggles auto-export after each assistant response.

SettingDefaultPurpose
atif_auto_exportoffWrite ATIF JSON after completion
jsonl_auto_exportoffSFT/DPO JSONL export

Research touchpoints

GapModuleWhy it matters
No Deserialize on ATIF typesM0Reflection must read traces back
No per-step ModuleIdM0GEPA credit assignment
No FeedbackFnM0GEPA µ_f, ACE reflector input
Full vs no retentionM0Recorder trait; no-op in release builds

Deep dive: M0 Trace module page, chatty-trace README.


Tools, sub-agents & workflow (M1, M2)

Production today

~60 native tools plus MCP integrations. Sub-agent tools compose other agents from the registry. Execution settings control workspace path, approval mode, and sandbox.

Tool clusterExamplesResearch use
Search / fetchsearch_web, fetchM1 WikiEnv adapter (paper fidelity); M6 Retrieval Part A (SimpleQA/FRAMES eval)
Coderun_command, sandboxM2 Programmer operator
Agentsinvoke_agentM2 Ensemble / Review-and-Revise nodes
Memoryremember, search_memoryM4 playbook backing store

Research touchpoints (AFlow)

Production substrateM2 uses it as
tool_registry / tool_collectorWorkflow node targets
invoke_agent_toolEnsemble branches
IrRepr interpreter (planned)Executes saved topology

Monty code mode (sandbox/monty_bridge.rs) could become PythonRepr for AFlow. Today MontySandbox (sandbox/monty.rs) runs stdlib-only Python through a python3 subprocess under time/memory limits, and SandboxManager tries it before Docker; the bridge’s ToolBridge interface exists but the pause/resume loop that would let scripts call Chatty tools is not wired. Source: crates/chatty-core/src/sandbox/.


Optimizer & offline runs (M2, M3)

Not in the request path. Search runs via chatty-optimize (planned CLI: chatty-tui --optimize, AGE-44).

OptimizerReads from appWrites to app
GEPA (M3)Traces, ModelConfig, cost fieldspreamble candidates
AFlow (M2)Traces, sub-agent registryWorkflow IR JSON
ACE offline (M4)Traces, memory storePlaybook delta ops

Stage B evals run in harbor-chatty, not inside the app binary.


Quick lookup: research module → app landing

ModuleLands in app at…Architecture doc
M0 Traceexporters/, StreamManager, future Recorderstream-manager.md
M1 ReActllm_service.rs, agent_factory/system-overview.md
M2 AFlowSub-agent tools + future FlowSettingsModelcomponent-map.md
M3 GEPAModelConfig.preamblesettings-integration-map
M4 ACEmemory_service, skill toolsagent-memory.md
M6 Retrievalsearch_web_tool.rs, fetch_tool.rs, search_memory_tool.rs, doc_retriever_tool.rsagent-memory.md, evals/search/README.md (archived)