Index
agents
¶
Agents primitive — multi-turn reasoning and tool use.
Classes¶
AgentContext
dataclass
¶
AgentContext(
conversation: Conversation = Conversation(),
tools: List[str] = list(),
memory_results: List[Any] = list(),
metadata: Dict[str, Any] = dict(),
)
Runtime context handed to an agent on each invocation.
AgentResult
dataclass
¶
AgentResult(
content: str,
tool_results: List[ToolResult] = list(),
turns: int = 0,
metadata: Dict[str, Any] = dict(),
)
Result returned after an agent completes a run.
BaseAgent
¶
BaseAgent(
engine: InferenceEngine,
model: str,
*,
bus: Optional[EventBus] = None,
temperature: Optional[float] = None,
max_tokens: Optional[int] = None,
prompt_builder: Optional[Any] = None,
)
Bases: ABC
Base class for all agent implementations.
Subclasses must be registered via
@AgentRegistry.register("name") to become discoverable.
Provides concrete helper methods that eliminate boilerplate in subclasses:
- :meth:
_emit_turn_start/ :meth:_emit_turn_end-- event bus - :meth:
_build_messages-- conversation + system prompt assembly - :meth:
_generate-- delegates to engine with stored defaults - :meth:
_max_turns_result-- standard max-turns-exceeded result - :meth:
_strip_think_tags-- remove<think>blocks
Source code in src/diapason/agents/_stubs.py
Methods:¶
run
abstractmethod
¶
run(
input: str,
context: Optional[AgentContext] = None,
**kwargs: Any,
) -> AgentResult
Execute the agent on input and return an AgentResult.
ToolUsingAgent
¶
ToolUsingAgent(
engine: InferenceEngine,
model: str,
*,
tools: Optional[List["BaseTool"]] = None,
bus: Optional[EventBus] = None,
max_turns: Optional[int] = None,
temperature: Optional[float] = None,
max_tokens: Optional[int] = None,
loop_guard_config: Optional[Any] = None,
capability_policy: Any = _SECURITY_CONTROL_UNSET,
boundary_guard: Optional[Any] = None,
rate_limiter: Optional[Any] = None,
agent_id: Optional[str] = None,
interactive: bool = False,
confirm_callback: Optional[Any] = None,
skill_few_shot_examples: Optional[List[str]] = None,
prompt_builder: Optional[Any] = None,
)
Bases: BaseAgent
Intermediate base for agents that accept and use tools.
Sets accepts_tools = True for CLI/SDK introspection, and
initialises a :class:ToolExecutor from the provided tools.
Source code in src/diapason/agents/_stubs.py
375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 | |