Skip to content

API Reference parrot.bots.database.retries

github-actions[bot] edited this page Dec 2, 2026 · 4 revisions

parrot.bots.database.retries

View source

Query retry handling — generalized for multiple database types.

Provides RetryHandler base class and SQLRetryHandler for SQL-specific error patterns. Stubs for Flux and DSL handlers are included for future use.

Class DSLRetryHandler

Elasticsearch DSL-specific retry handler (stub for future use).

Parameter Type Default Description
toolkit Any None
config Optional[QueryRetryConfig] None

Class FluxRetryHandler

InfluxDB Flux-specific retry handler (stub for future use).

Parameter Type Default Description
toolkit Any None
config Optional[QueryRetryConfig] None

Class QueryRetryConfig

Configuration for query retry mechanism.

Parameter Type Default Description
max_retries int 3
retry_on_errors Optional[List[str]] None
sample_data_on_error bool True
max_sample_rows int 3
database_type str 'sql'

Class RetryContext

Payload returned by SQLToolkit.execute_query on a retryable error.

Signals to DatabaseAgent.ask() that the last query failed but is worth retrying. The LLM receives this context on the re-ask so it can generate a corrected query.

Fields:

Field Type Default Description
query str The SQL query that failed.
error str Error message from the database.
attempt int Retry attempt number (1-based).
sample_data str '' Sample data context for the failing table/column.
suggested_correction Optional[str] None Suggested query correction from the retry handler, if any.

Class RetryHandler

Base retry handler for any database toolkit.

Subclass and override _is_retryable_error and retry_query for database-specific error patterns.

Parameter Type Default Description
toolkit Any None
config Optional[QueryRetryConfig] None

Method RetryHandler.retry_query

Attempt to produce a corrected query after an error.

retry_query(query: str, error: Exception, attempt: int) -> Optional[str]

Parameter Type Default Description
query str The query that failed.
error Exception The exception from execution.
attempt int Current retry attempt number.

Returns: Optional[str] — A corrected query string, or None if no correction possible.

Class SQLRetryHandler

SQL-specific retry handler with error learning.

Parameter Type Default Description
toolkit Any None
config Optional[QueryRetryConfig] None
agent Any None

Method SQLRetryHandler.retry_query

Attempt to produce a corrected SQL query.

Extracts table/column info from the error, fetches sample data, and provides context for correction.

retry_query(query: str, error: Exception, attempt: int) -> Optional[str]

Parameter Type Default Description
query str
error Exception
attempt int

Returns: Optional[str]

Architecture

Clients

Bots & Agents

Memory

Knowledge

Tools & Toolkits

Flows

Experts

Skills

Stores & Loaders

MCP & A2A

Server & APIs

Integrations

Outputs & A2UI

Prompts

Security

Operations

Migration

SDD Tooling

LLM Wiki

Deployment

Decisions

API Reference

Clone this wiki locally