AI Assistant Guidelines - Agents Framework
On Sun, 04 Oct 2026, by @lucasdicioccio, 549 words, 15 code snippets, 0 links, 0images.
Generated from documentation/ai-assistant-guidelines.md, the repository is the canonical source and may be ahead of this page.
AI Assistant Guidelines - Agents Framework
This document provides guidance for AI assistants (including future instances of myself) working on the Agents framework codebase.
Quick Start for AI Assistants
First Steps
When invoked on this codebase, always:
- Check the knowledge base - Query
sqlite_knowledge_store_queryfor existing state - Review recent commits - Use
bash_get_git_logto see what’s changed - Check existing docs - Review
docs_indextable for current documentation - Identify the task - Understand what changes or documentation are needed
Essential Queries
-- Get project overview
SELECT * FROM project_overview;
-- List all documented modules
SELECT * FROM code_index WHERE documented_in IS NOT NULL;
-- Find undocumented modules
SELECT filepath, module_name FROM code_index WHERE documented_in IS NULL;
-- Check existing documentation
SELECT * FROM docs_index;Knowledge Base Structure
Tables
| Table | Purpose |
|---|---|
commits_seen | Git commits already processed |
project_overview | High-level project information |
code_index | All source modules with metadata |
docs_index | Documentation files index |
Code Index Schema
-- Track which modules are documented where
SELECT
filepath,
module_name,
purpose,
documented_in,
last_updated
FROM code_index
ORDER BY filepath;Documentation Index Schema
-- Check documentation coverage
SELECT
doc_path,
title,
description,
related_modules
FROM docs_index
ORDER BY doc_path;Documentation Standards
File Organization
documentation/
├── README.md # Project overview (always up to date)
├── architecture.md # System architecture
├── tools.md # Tool system
├── mcp.md # MCP protocol
├── sessions.md # Session management
├── tui.md # Terminal UI
├── cli-commands.md # CLI reference
├── export-import.md # Tool sharing
├── file-loader.md # File loading utilities
└── ai-assistant-guidelines.md # This file
Documentation Format
All docs should:
- Use Markdown format
- Include ASCII diagrams for architecture (Graphviz when complex)
- Provide Haskell type definitions for key types
- Include code examples
- Have a Table of Contents for longer docs
- Reference related modules in
System.Agents.*namespace
Graphviz Guidelines
When creating diagrams:
- Save dot files to
documentation/*.dot - Generate PNGs with matching names
- Keep diagrams focused on one concept
- Use consistent styling
// documentation/example.dot
digraph Architecture {
rankdir=TB;
node [shape=box, style=rounded];
Main -> AgentTree;
AgentTree -> Runtime;
Runtime -> Session;
Runtime -> Tools;
}Working with the Codebase
Module Categories
| Category | Path Pattern | Doc Reference |
|---|---|---|
| Core | System.Agents.Base, System.Agents.Runtime* | architecture.md |
| CLI | app/Main.hs, System.Agents.CLI.* | cli-commands.md |
| Tools | System.Agents.Tools.* | tools.md |
| MCP | System.Agents.MCP.* | mcp.md |
| Sessions | System.Agents.Session.* | sessions.md |
| TUI | System.Agents.TUI.* | tui.md |
| Export/Import | System.Agents.ExportImport.* | export-import.md |
| File Loading | System.Agents.FileLoader* | file-loader.md |
Key Types to Document
When encountering new types, always document:
- Purpose - What problem does this solve?
- Fields - What does each field represent?
- Relationships - How does it connect to other types?
- Usage examples - How is it used in practice?
Tracing Conventions
The codebase uses Prod.Tracer extensively:
-- All significant operations should be traced
data Trace
= OperationStart Param
| OperationComplete Result
| OperationError Error
-- Use contramap for sub-tracers
subTracer :: Tracer IO ParentTrace -> Tracer IO ChildTrace
subTracer = contramap ParentConstructorMaintenance Tasks
Keeping Documentation Current
When code changes:
-
Identify affected docs:
SELECT doc_path FROM docs_index WHERE related_modules LIKE '%ModuleName%'; -
Update code_index:
UPDATE code_index SET documented_in = 'documentation/file.md', last_updated = datetime('now') WHERE module_name = 'System.Agents.Module'; -
Review and update the relevant doc file
Adding New Modules
When new modules are added:
-
Add to
code_index:INSERT INTO code_index (filepath, module_name, purpose, last_updated) VALUES ('src/System/Agents/NewModule.hs', 'System.Agents.NewModule', 'Description of purpose', datetime('now')); -
Determine if new documentation needed
-
Update existing docs with cross-references
Handling Commits
Track commits in commits_seen:
-- After processing a commit
INSERT INTO commits_seen (commit_hash, commit_date, commit_message)
VALUES ('abc123...', '2024-01-15', 'message');Common Patterns
Agent Configuration
Agents are configured via JSON:
{
"slug": "agent-name",
"apiKeyId": "key-ref",
"flavor": "openai",
"modelUrl": "https://api.openai.com/v1",
"modelName": "gpt-4",
"announce": "Description",
"systemPrompt": ["Instructions"],
"toolDirectory": "tools",
"mcpServers": [...],
"extraAgents": [...]
}Tool Definition
Tools follow this pattern:
data ToolRegistration = ToolRegistration
{ toolName :: Text
, toolDescription :: Text
, toolParameters :: Value -- JSON Schema
, toolExecutor :: Value -> IO ToolResult
}Session Flow
User Input -> Session -> LLM Call -> Tool Execution -> Response -> Persist Session
Documentation Gaps to Watch For
Watch for these common omissions:
- New CLI commands - Update
cli-commands.md - New tool types - Update
tools.md - API changes - Document breaking changes
- Configuration options - Keep examples current
- Error types - Document error conditions
Questions to Ask
When documentation is unclear:
- What is the purpose of this module/component?
- How does it relate to other parts of the system?
- What are the key data types?
- What is the typical usage flow?
- Are there any gotchas or edge cases?
Iterative Documentation Workflow
For large documentation tasks:
- Plan - List all modules/files to document
- Chunk - Work on one subsystem at a time
- Query - Check knowledge base for existing state
- Write - Create/update markdown files
- Index - Update
docs_indexandcode_index - Review - Check for consistency and completeness
- Commit - First line of response should be summary
Summary Line Format
The first line of every response should be a concise summary:
Brief description of what was done or discovered
Examples:
- “Updated tool system documentation with OpenAPI toolbox details”
- “Discovered undocumented MCP server configuration types”
- “Created architecture diagram for agent tree system”
Self-Correction Checklist
Before completing work:
- [ ] Knowledge base tables are consistent
- [ ] All new modules indexed in
code_index - [ ] Documentation links are valid
- [ ] Code examples compile (if applicable)
- [ ] ASCII diagrams render correctly
- [ ] Summary line is present
- [ ] Related modules cross-referenced
Emergency Recovery
If knowledge base is corrupted:
- Rebuild
code_indexby scanning all.hsfiles - Rebuild
docs_indexby listingdocumentation/*.mdfiles - Update
project_overviewwith basic project info - Re-link modules to documentation manually
Useful One-Liners
# Count modules by subsystem
ghc -i src -e ":browse System.Agents.Tools" 2>/dev/null | wc -l
# Find undocumented exports
find src -name "*.hs" -exec grep -l "^module " {} \; | while read f; do
mod=$(grep "^module " "$f" | head -1 | awk '{print $2}')
# Check if in code_index...
done
# List all types in a module
ghc -i src -e ":browse System.Agents.Base" 2>/dev/null | grep "data "Contact Points
Key files for understanding the system:
| File | Why It's Important |
|---|---|
app/Main.hs | Entry point, CLI commands |
src/System/Agents/Base.hs | Core types |
src/System/Agents/AgentTree.hs | Multi-agent orchestration |
src/System/Agents/Runtime/Runtime.hs | Execution engine |
agents.cabal | Dependencies and build config |
Remember: This documentation is for AI assistants. Keep it practical, specific to this codebase, and actionable.