Are you an LLM? Read llms.txt for a summary of the docs, or llms-full.txt for the full context.
Skip to content

Coding Agent Integration

Terminal commands, file edits, error tracking, and user intent.

What Coding Agents Know

Coding agents generate unique knowledge that compounds across sessions: commands run, files edited, errors hit, and user instructions. Storing this knowledge turns a stateless tool into a learning assistant.

Event Types for Coding Agents

Terminal Commands

Store commands as action events. Include the result and duration for future reference.

await client.storeEvent({
  graph_id: 'project-x',
  event_kind: 'action',
  source: 'executor',
  context_id: 'project:api_server',
  payload: { command: 'cargo test', result: 'PASS', duration_ms: 3200 },
});

Errors

Store errors as observation events. Track which errors recur and what fixed them.

await client.storeEvent({
  graph_id: 'project-x',
  event_kind: 'observation',
  source: 'agent',
  context_id: 'error:null_pointer',
  payload: { file: 'src/auth.rs', line: 42, message: 'unwrap on None value', fix: 'Use Option::unwrap_or_default()' },
});

User Intent

Store what the user asked for and why as decision events. This helps the agent align future actions with user preferences.

await client.storeEvent({
  graph_id: 'project-x',
  event_kind: 'decision',
  source: 'user',
  context_id: 'intent:refactor',
  payload: { topic: 'error_handling', value: 'User wants all unwrap calls replaced with proper error handling' },
});

Retrieve Before Acting

Before executing a task, query the graph for relevant patterns and past errors. This prevents the agent from repeating known mistakes.

const context = await client.retrieveMemories({
  query: 'auth module errors and fixes',
  limit: 5,
  contextTypes: { error: ['null_pointer', 'auth_failure'] },
});

Always retrieve before acting on files you have edited before. The graph may contain fixes for errors you are about to reintroduce.

Context Prefix Guide

Use consistent prefixes to organize coding knowledge:

PrefixPurposeExample
project:Project-level factsproject:api_server
error:Error patterns and fixeserror:null_pointer
file:File-specific knowledgefile:src/auth.rs
intent:User instructionsintent:refactor
test:Test results and patternstest:integration

Store the fix alongside the error. When the same error surfaces again, the agent retrieves both the problem and the solution in one query.

Next

Single Agent Loop
The foundation pattern for all agent workflows.
Common Patterns
Reusable patterns for building with LocusGraph.