Skip to content

chimera.core

chimera.core is the heart of the agent: the Agent class, the conversation Context, the ReAct loop with all its lifecycle hooks, and the base classes for tools and prompts.

SymbolModulePurpose
Agentchimera.core.agentMain entry point. Agent(provider, tools, loop=..., prompt=...). Methods: run(task, env=None), iter_steps(task, env=None).
Contextchimera.core.contextConversation history manager. Tracks messages, tool calls/results, system prompts.
ReActchimera.core.loopThe default reason-act-observe loop. Stream-level cancellation, steering drain, 10 lifecycle event emissions.
LoopConfigchimera.core.loop_configSingle dataclass that funnels every loop-level feature: permissions, detection, events, audit, checkpoints, git workflow, cancellation, message queues, file tracker. None everywhere = unchanged behaviour.
ToolExecutorchimera.core.tool_executorShared tool-execution path with permission / event / detection / audit / cancellation / file-tracking hooks.
Promptchimera.core.promptSystem-prompt builder with {var} substitution. Prompt.from_string(s), Prompt.from_template(...).

Tools (chimera.core.tool, chimera.core.tool_group)

Section titled “Tools (chimera.core.tool, chimera.core.tool_group)”
SymbolPurpose
BaseToolABC. Define name, description, parameters (JSON Schema), execute(args, env).
@tool(name=, description=, parameters=)Decorator that wraps a plain function.
ToolGroupIterable bundle of tools.
DEFAULT_TOOLSStandard toolset (read, write, edit, bash, search, …).
create_default_tools(ops=None)Factory; pass a custom Operations to swap filesystem / shell / search backends.
from chimera.core.cancellation import CancellationToken, OperationCancelled, CancellableTool
SymbolPurpose
CancellationTokenThread-safe cooperative cancel. .cancel(), .is_cancelled.
OperationCancelledException raised by tools that observe a cancelled token.
CancellableToolMixin that injects token-checking into the tool’s execute.

The REPL’s Ctrl-C handler triggers CancellationToken.cancel(); the loop drains the streamer and surfaces a prompt for the next user message.

from chimera.core.file_tracker import FileTracker

FileTracker records every file read or written by a session and survives compaction boundaries (so a compacted summary can still cite which files the agent has already looked at).

Message queues (chimera.core.message_queue)

Section titled “Message queues (chimera.core.message_queue)”
from chimera.core.message_queue import MessageQueues

Two thread-safe queues:

  • Steering queue — user messages injected mid-turn (consumed at the next step boundary).
  • Follow-up queue — user messages queued for the next turn (consumed when the current turn completes).

Protocol-based filesystem / shell / search abstraction. Implementations plug into create_default_tools(ops=...) so tools can be tested without a real filesystem or sandboxed for remote execution.

ProtocolLocal impl
ReadOpsLocalReadOps
WriteOpsLocalWriteOps
BashOpsLocalBashOps
SearchOpsLocalSearchOps
ModuleLoop
chimera.core.loops.plan_and_executePlanAndExecute — plan-mode → act-mode handoff.
chimera.core.loops.reflexionReflexion — self-critique with retry.
chimera.core.loops.tree_of_thoughtTreeOfThought — branch-and-prune search.