AI Memory & History

AI agents frequently make database query errors because they lack knowledge of team-specific business definitions, deprecated columns, and soft-delete setups. Bollard resolves this by providing a local learning loop and session context tracking history.

1. The Corrections Loop

If an AI agent compiles a query that is syntactically valid but semantically incorrect (such as querying signup_date instead of the updated created_at column), you can log a correction:

log_correction(
  connection="local_pg",
  original_query="SELECT * FROM users WHERE signup_date > '2026-01-01';",
  corrected_query="SELECT * FROM users WHERE created_at > '2026-01-01';",
  note="signup_date column is deprecated. Always use created_at."
)

Bollard persists this correction payload in your local user data directory. The next time the AI agent queries the database, it loads the corrections database and uses it as context to adjust its SQL generation.

1

Developer logs correction

Call the MCP tool log_correction(connection, original_query, corrected_query, note)

2

Stored in local database

Persisted to corrections.json in user data directory on disk

3

AI Agent reads resource

Fetches bollard://corrections/local_pg at the start of each session

4

Automatic context injection

Agent avoids deprecated columns in all future queries automatically

Example Correction
{
  "table": "users",
  "column": "user_name",
  "note": "Use full_name"
}

2. Query History Resources

Bollard tracks the last 100 queries run on an active connection. The server exposes this log buffer to the client editor as a protocol resource:

bollard://history/{connection_alias}

The AI reads this history block at the start of each query turn to maintain session context, allowing it to remember past actions, schemas checked, and results without requiring you to re-explain the current state.

3. Active Connections and Policies Resources

Bollard exposes two other system resources:

  • bollard://connections: Read by the AI agent on startup to discover active database aliases, dialects, and permissions.
  • bollard://policies/{alias}: Contains detailed information regarding active connection mode policies, LIMIT defaults, and forbidden tables.