Saltar a contenido

API reference

Generated from the apogee-ai source with mkdocstrings. Every symbol below is exported from apogee_ai, so it is part of the supported public surface.

Other

ActionAuditPort

Bases: Protocol

Records an audited action (adapter delegates to ai-audit's hash-chain).

record_tool async

Python
record_tool(ctx: GovernanceContext, *, tool_name: str, status: str, detail: str = '') -> None
Source code in apogee_ai/domain/services/i_governance.py
Python
async def record_tool(
    self,
    ctx: GovernanceContext,
    *,
    tool_name: str,
    status: str,
    detail: str = "",
) -> None:
    ...

Agent dataclass

Python
Agent(name: str = '', slug: str = '', version: str = '0.1.0', description: str = '', status: AgentStatusEnum = DRAFT, visibility: AgentVisibilityEnum = PRIVATE, owner_id: str | None = None, tags: list[str] = list(), agent_type: AgentTypeEnum = WORKER, execution_pattern: ExecutionPatternEnum = REACT, collaboration_pattern: CollaborationPatternEnum = HIERARCHICAL, engine: EngineBinding = EngineBinding(), model: ModelConfig = ModelConfig(), prompt: PromptConfig = PromptConfig(), memory: MemoryConfig = MemoryConfig(), runtime: RuntimeConfig = RuntimeConfig(), tools: list[ToolBinding] = list(), managed_agents: list[str] = list(), parent_supervisor_id: str | None = None)

Bases: BaseEntity

Root aggregate representing a configurable AI agent.

Carries identity + the full versioned configuration. In a future iteration we may split identity (Agent) from config (AgentVersion) as discussed in the architectural plan; for the MVP they live together.

name class-attribute instance-attribute

Python
name: str = ''

slug class-attribute instance-attribute

Python
slug: str = ''

version class-attribute instance-attribute

Python
version: str = '0.1.0'

description class-attribute instance-attribute

Python
description: str = ''

status class-attribute instance-attribute

Python
status: AgentStatusEnum = DRAFT

visibility class-attribute instance-attribute

Python
visibility: AgentVisibilityEnum = PRIVATE

owner_id class-attribute instance-attribute

Python
owner_id: str | None = None

tags class-attribute instance-attribute

Python
tags: list[str] = field(default_factory=list)

agent_type class-attribute instance-attribute

Python
agent_type: AgentTypeEnum = WORKER

execution_pattern class-attribute instance-attribute

Python
execution_pattern: ExecutionPatternEnum = REACT

collaboration_pattern class-attribute instance-attribute

Python
collaboration_pattern: CollaborationPatternEnum = HIERARCHICAL

engine class-attribute instance-attribute

Python
engine: EngineBinding = field(default_factory=EngineBinding)

model class-attribute instance-attribute

Python
model: ModelConfig = field(default_factory=ModelConfig)

prompt class-attribute instance-attribute

Python
prompt: PromptConfig = field(default_factory=PromptConfig)

memory class-attribute instance-attribute

Python
memory: MemoryConfig = field(default_factory=MemoryConfig)

runtime class-attribute instance-attribute

Python
runtime: RuntimeConfig = field(default_factory=RuntimeConfig)

tools class-attribute instance-attribute

Python
tools: list[ToolBinding] = field(default_factory=list)

managed_agents class-attribute instance-attribute

Python
managed_agents: list[str] = field(default_factory=list)

parent_supervisor_id class-attribute instance-attribute

Python
parent_supervisor_id: str | None = None

AgentEvent dataclass

Python
AgentEvent(kind: str, content: str, metadata: dict[str, Any] = dict())

kind instance-attribute

Python
kind: str

content instance-attribute

Python
content: str

metadata class-attribute instance-attribute

Python
metadata: dict[str, Any] = field(default_factory=dict)

AgentInput dataclass

Python
AgentInput(user_input: str, history: list[Message] = list(), metadata: dict[str, Any] = dict())

user_input instance-attribute

Python
user_input: str

history class-attribute instance-attribute

Python
history: list[Message] = field(default_factory=list)

metadata class-attribute instance-attribute

Python
metadata: dict[str, Any] = field(default_factory=dict)

AgentOutput dataclass

Python
AgentOutput(final_response: str, messages: list[Message] = list(), iterations: int = 0, finish_reason: str = 'stop', metadata: dict[str, Any] = dict())

final_response instance-attribute

Python
final_response: str

messages class-attribute instance-attribute

Python
messages: list[Message] = field(default_factory=list)

iterations class-attribute instance-attribute

Python
iterations: int = 0

finish_reason class-attribute instance-attribute

Python
finish_reason: str = 'stop'

metadata class-attribute instance-attribute

Python
metadata: dict[str, Any] = field(default_factory=dict)

ApprovalDecision dataclass

Python
ApprovalDecision(approved: bool, feedback: str = '', overrides: dict[str, Any] = dict())

approved instance-attribute

Python
approved: bool

feedback class-attribute instance-attribute

Python
feedback: str = ''

overrides class-attribute instance-attribute

Python
overrides: dict[str, Any] = field(default_factory=dict)

ApprovalRequest dataclass

Python
ApprovalRequest(kind: str, payload: dict[str, Any] = dict(), metadata: dict[str, Any] = dict())

Snapshot of state the human is asked to approve.

kind instance-attribute

Python
kind: str

payload class-attribute instance-attribute

Python
payload: dict[str, Any] = field(default_factory=dict)

metadata class-attribute instance-attribute

Python
metadata: dict[str, Any] = field(default_factory=dict)

BudgetGuardPort

Bases: Protocol

Pre-call gate + post-call charge (adapter delegates to ai-context-budget).

allow async

Python
allow(ctx: GovernanceContext) -> BudgetVerdict
Source code in apogee_ai/domain/services/i_governance.py
Python
async def allow(self, ctx: GovernanceContext) -> BudgetVerdict:
    ...

charge async

Python
charge(ctx: GovernanceContext, *, prompt_tokens: int, completion_tokens: int) -> None
Source code in apogee_ai/domain/services/i_governance.py
Python
async def charge(
    self, ctx: GovernanceContext, *, prompt_tokens: int, completion_tokens: int
) -> None:
    ...

BudgetVerdict dataclass

Python
BudgetVerdict(allowed: bool, reason: str = 'ok')

Result of a pre-call budget/rate check.

allowed instance-attribute

Python
allowed: bool

reason class-attribute instance-attribute

Python
reason: str = 'ok'

CompiledAgent dataclass

Python
CompiledAgent(agent: Agent, deps: EngineDependencies, native_object: Any = None)

agent instance-attribute

Python
agent: Agent

deps instance-attribute

Python
deps: EngineDependencies

native_object class-attribute instance-attribute

Python
native_object: Any = None

ContextManagerPort

Bases: Protocol

Fits the running message window (adapter delegates to ai-context-budget).

fit_messages

Python
fit_messages(messages: list[Message]) -> list[Message]
Source code in apogee_ai/domain/services/i_governance.py
Python
def fit_messages(self, messages: list[Message]) -> list[Message]:
    ...

Conversation dataclass

Python
Conversation(agent_slug: str = '', user_id: str | None = None, title: str = '', messages: list[Message] = list(), closed: bool = False)

Bases: BaseEntity

agent_slug class-attribute instance-attribute

Python
agent_slug: str = ''

user_id class-attribute instance-attribute

Python
user_id: str | None = None

title class-attribute instance-attribute

Python
title: str = ''

messages class-attribute instance-attribute

Python
messages: list[Message] = field(default_factory=list)

closed class-attribute instance-attribute

Python
closed: bool = False

append

Python
append(message: Message) -> None
Source code in apogee_ai/domain/entities/conversation.py
Python
def append(self, message: Message) -> None:
    self.messages.append(message)

Document dataclass

Python
Document(text: str, metadata: dict = dict(), id: str = (lambda: f'doc_{hex[:12]}')(), embedding: list[float] = list())

text instance-attribute

Python
text: str

metadata class-attribute instance-attribute

Python
metadata: dict = field(default_factory=dict)

id class-attribute instance-attribute

Python
id: str = field(default_factory=lambda: f'doc_{hex[:12]}')

embedding class-attribute instance-attribute

Python
embedding: list[float] = field(default_factory=list)

EngineBinding dataclass

Python
EngineBinding(kind: EngineKindEnum = NATIVE, options: dict[str, Any] = dict())

kind class-attribute instance-attribute

Python
kind: EngineKindEnum = NATIVE

options class-attribute instance-attribute

Python
options: dict[str, Any] = field(default_factory=dict)

EngineDependencies dataclass

Python
EngineDependencies(llm_client: ILLMClient, tool_executor: Any | None = None, extras: dict[str, Any] = dict())

llm_client instance-attribute

Python
llm_client: ILLMClient

tool_executor class-attribute instance-attribute

Python
tool_executor: Any | None = None

extras class-attribute instance-attribute

Python
extras: dict[str, Any] = field(default_factory=dict)

EvalCase dataclass

Python
EvalCase(name: str, input: str, matchers: list[Matcher] = list(), metadata: dict = dict())

name instance-attribute

Python
name: str

input instance-attribute

Python
input: str

matchers class-attribute instance-attribute

Python
matchers: list[Matcher] = field(default_factory=list)

metadata class-attribute instance-attribute

Python
metadata: dict = field(default_factory=dict)

EvalCaseResult dataclass

Python
EvalCaseResult(name: str, passed: bool, output: str, failed_matchers: list[int] = list())

name instance-attribute

Python
name: str

passed instance-attribute

Python
passed: bool

output instance-attribute

Python
output: str

failed_matchers class-attribute instance-attribute

Python
failed_matchers: list[int] = field(default_factory=list)

EvalReport dataclass

Python
EvalReport(suite: str, results: list[EvalCaseResult] = list())

suite instance-attribute

Python
suite: str

results class-attribute instance-attribute

Python
results: list[EvalCaseResult] = field(default_factory=list)

passed property

Python
passed: int

failed property

Python
failed: int

total property

Python
total: int

EvalRunner

Python
EvalRunner(executor: AgentExecutor)
Source code in apogee_ai/application/eval/eval_runner.py
Python
def __init__(self, executor: AgentExecutor) -> None:
    self._exec = executor

run async

Python
run(suite: EvalSuite, agent: Agent) -> EvalReport
Source code in apogee_ai/application/eval/eval_runner.py
Python
async def run(self, suite: EvalSuite, agent: Agent) -> EvalReport:
    report = EvalReport(suite=suite.name)
    for case in suite.cases:
        output = await self._exec(agent, case.input)
        failed: list[int] = []
        for idx, matcher in enumerate(case.matchers):
            if not matcher(output):
                failed.append(idx)
        report.results.append(
            EvalCaseResult(
                name=case.name,
                passed=not failed,
                output=output,
                failed_matchers=failed,
            )
        )
    return report

EvalSuite dataclass

Python
EvalSuite(name: str, cases: list[EvalCase] = list())

name instance-attribute

Python
name: str

cases class-attribute instance-attribute

Python
cases: list[EvalCase] = field(default_factory=list)

ExecutionTrace dataclass

Python
ExecutionTrace(agent_slug: str = '', conversation_id: str | None = None, user_input: str = '', final_response: str = '', iterations: int = 0, finish_reason: str = 'stop', steps: list[TraceStep] = list(), tokens_prompt: int = 0, tokens_completion: int = 0, cost_usd: float = 0.0, metadata: dict[str, Any] = dict())

Bases: BaseEntity

agent_slug class-attribute instance-attribute

Python
agent_slug: str = ''

conversation_id class-attribute instance-attribute

Python
conversation_id: str | None = None

user_input class-attribute instance-attribute

Python
user_input: str = ''

final_response class-attribute instance-attribute

Python
final_response: str = ''

iterations class-attribute instance-attribute

Python
iterations: int = 0

finish_reason class-attribute instance-attribute

Python
finish_reason: str = 'stop'

steps class-attribute instance-attribute

Python
steps: list[TraceStep] = field(default_factory=list)

tokens_prompt class-attribute instance-attribute

Python
tokens_prompt: int = 0

tokens_completion class-attribute instance-attribute

Python
tokens_completion: int = 0

cost_usd class-attribute instance-attribute

Python
cost_usd: float = 0.0

metadata class-attribute instance-attribute

Python
metadata: dict[str, Any] = field(default_factory=dict)

add_step

Python
add_step(step: TraceStep) -> None
Source code in apogee_ai/domain/entities/execution_trace.py
Python
def add_step(self, step: TraceStep) -> None:
    self.steps.append(step)

GovernanceContext dataclass

Python
GovernanceContext(agent_slug: str, run_id: str = '', metadata: dict[str, Any] = dict())

Per-run context passed to every governance hook.

agent_slug instance-attribute

Python
agent_slug: str

run_id class-attribute instance-attribute

Python
run_id: str = ''

metadata class-attribute instance-attribute

Python
metadata: dict[str, Any] = field(default_factory=dict)

GovernanceDeps dataclass

Python
GovernanceDeps(tool_guard: ToolGuardPort | None = None, audit: ActionAuditPort | None = None, budget: BudgetGuardPort | None = None, context: ContextManagerPort | None = None)

Optional governance hooks injected via EngineDependencies.extras['governance'].

Every field is optional; a None field disables that hook. An absent GovernanceDeps (the default) disables all of them.

tool_guard class-attribute instance-attribute

Python
tool_guard: ToolGuardPort | None = None

audit class-attribute instance-attribute

Python
audit: ActionAuditPort | None = None

budget class-attribute instance-attribute

Python
budget: BudgetGuardPort | None = None

context class-attribute instance-attribute

Python
context: ContextManagerPort | None = None

GuardVerdict dataclass

Python
GuardVerdict(allowed: bool, reason: str = 'ok')

Result of an authorization check on a tool call.

allowed instance-attribute

Python
allowed: bool

reason class-attribute instance-attribute

Python
reason: str = 'ok'

GuardrailResult dataclass

Python
GuardrailResult(allowed: bool, redacted_text: str, reason: str = '')

allowed instance-attribute

Python
allowed: bool

redacted_text instance-attribute

Python
redacted_text: str

reason class-attribute instance-attribute

Python
reason: str = ''

IngestRequest dataclass

Python
IngestRequest(texts: list[str], metadatas: list[dict] = list())

texts instance-attribute

Python
texts: list[str]

metadatas class-attribute instance-attribute

Python
metadatas: list[dict] = field(default_factory=list)

KnowledgeSource dataclass

Python
KnowledgeSource(name: str = '', description: str = '', vector_store_id: str = '', embedding_model: str = 'text-embedding-3-small', metadata: dict = dict())

Bases: BaseEntity

name class-attribute instance-attribute

Python
name: str = ''

description class-attribute instance-attribute

Python
description: str = ''

vector_store_id class-attribute instance-attribute

Python
vector_store_id: str = ''

embedding_model class-attribute instance-attribute

Python
embedding_model: str = 'text-embedding-3-small'

metadata class-attribute instance-attribute

Python
metadata: dict = field(default_factory=dict)

LLMRequest dataclass

Python
LLMRequest(messages: list[Message], model: ModelConfig, stop: list[str] = list(), tools: list[ToolSchema] = list())

messages instance-attribute

Python
messages: list[Message]

model instance-attribute

Python
model: ModelConfig

stop class-attribute instance-attribute

Python
stop: list[str] = field(default_factory=list)

tools class-attribute instance-attribute

Python
tools: list[ToolSchema] = field(default_factory=list)

LLMResponse dataclass

Python
LLMResponse(content: str, finish_reason: str = 'stop', prompt_tokens: int = 0, completion_tokens: int = 0, raw: dict | None = None, tool_calls: list[ToolCall] = list())

content instance-attribute

Python
content: str

finish_reason class-attribute instance-attribute

Python
finish_reason: str = 'stop'

prompt_tokens class-attribute instance-attribute

Python
prompt_tokens: int = 0

completion_tokens class-attribute instance-attribute

Python
completion_tokens: int = 0

raw class-attribute instance-attribute

Python
raw: dict | None = None

tool_calls class-attribute instance-attribute

Python
tool_calls: list[ToolCall] = field(default_factory=list)

MemoryConfig dataclass

Python
MemoryConfig(strategy: MemoryStrategyEnum = SLIDING_WINDOW, context_window: int = 8000, long_term: bool = False, store: str = 'in_memory', session_timeout: int = 3600)

strategy class-attribute instance-attribute

context_window class-attribute instance-attribute

Python
context_window: int = 8000

long_term class-attribute instance-attribute

Python
long_term: bool = False

store class-attribute instance-attribute

Python
store: str = 'in_memory'

session_timeout class-attribute instance-attribute

Python
session_timeout: int = 3600

Message dataclass

Python
Message(role: RoleEnum, content: str, name: str | None = None, tool_calls: list[dict[str, Any]] = list(), created_at: datetime = (lambda: now(utc))())

role instance-attribute

Python
role: RoleEnum

content instance-attribute

Python
content: str

name class-attribute instance-attribute

Python
name: str | None = None

tool_calls class-attribute instance-attribute

Python
tool_calls: list[dict[str, Any]] = field(default_factory=list)

created_at class-attribute instance-attribute

Python
created_at: datetime = field(default_factory=lambda: now(utc))

ModelConfig dataclass

Python
ModelConfig(provider: LLMProviderEnum = ECHO, model: str = 'echo', temperature: float = 0.7, max_tokens: int = 1024, top_p: float = 1.0, top_k: int | None = None, frequency_penalty: float = 0.0, presence_penalty: float = 0.0, stop_sequences: list[str] = list(), response_format: str = 'text', fallback_model: str | None = None)

provider class-attribute instance-attribute

Python
provider: LLMProviderEnum = ECHO

model class-attribute instance-attribute

Python
model: str = 'echo'

temperature class-attribute instance-attribute

Python
temperature: float = 0.7

max_tokens class-attribute instance-attribute

Python
max_tokens: int = 1024

top_p class-attribute instance-attribute

Python
top_p: float = 1.0

top_k class-attribute instance-attribute

Python
top_k: int | None = None

frequency_penalty class-attribute instance-attribute

Python
frequency_penalty: float = 0.0

presence_penalty class-attribute instance-attribute

Python
presence_penalty: float = 0.0

stop_sequences class-attribute instance-attribute

Python
stop_sequences: list[str] = field(default_factory=list)

response_format class-attribute instance-attribute

Python
response_format: str = 'text'

fallback_model class-attribute instance-attribute

Python
fallback_model: str | None = None

PromptConfig dataclass

Python
PromptConfig(system: str = 'You are a helpful assistant.', persona: str | None = None, language: str = 'pt-BR', greeting: str | None = None, template_ref: str | None = None, few_shot_examples: list[dict[str, str]] = list(), output_template: str | None = None)

system class-attribute instance-attribute

Python
system: str = 'You are a helpful assistant.'

persona class-attribute instance-attribute

Python
persona: str | None = None

language class-attribute instance-attribute

Python
language: str = 'pt-BR'

greeting class-attribute instance-attribute

Python
greeting: str | None = None

template_ref class-attribute instance-attribute

Python
template_ref: str | None = None

few_shot_examples class-attribute instance-attribute

Python
few_shot_examples: list[dict[str, str]] = field(default_factory=list)

output_template class-attribute instance-attribute

Python
output_template: str | None = None

RetrievedDocument dataclass

Python
RetrievedDocument(document: Document, score: float)

document instance-attribute

Python
document: Document

score instance-attribute

Python
score: float

RuntimeConfig dataclass

Python
RuntimeConfig(max_iterations: int = 8, timeout_seconds: int = 60, streaming_enabled: bool = False, retry_attempts: int = 2, retry_backoff: str = 'exponential', fallback_agent_id: str | None = None)

max_iterations class-attribute instance-attribute

Python
max_iterations: int = 8

timeout_seconds class-attribute instance-attribute

Python
timeout_seconds: int = 60

streaming_enabled class-attribute instance-attribute

Python
streaming_enabled: bool = False

retry_attempts class-attribute instance-attribute

Python
retry_attempts: int = 2

retry_backoff class-attribute instance-attribute

Python
retry_backoff: str = 'exponential'

fallback_agent_id class-attribute instance-attribute

Python
fallback_agent_id: str | None = None

Tool dataclass

Python
Tool(name: str = '', description: str = '', json_schema: dict[str, Any] = dict(), implementation_ref: str = '')

Bases: BaseEntity

name class-attribute instance-attribute

Python
name: str = ''

description class-attribute instance-attribute

Python
description: str = ''

json_schema class-attribute instance-attribute

Python
json_schema: dict[str, Any] = field(default_factory=dict)

implementation_ref class-attribute instance-attribute

Python
implementation_ref: str = ''

Where the tool lives, e.g. python::module.func, mcp://server/tool, http://... or builtin::echo.

ToolBinding dataclass

Python
ToolBinding(tool_id: str, enabled: bool = True, scope: list[str] = list())

tool_id instance-attribute

Python
tool_id: str

enabled class-attribute instance-attribute

Python
enabled: bool = True

scope class-attribute instance-attribute

Python
scope: list[str] = field(default_factory=list)

ToolCall dataclass

Python
ToolCall(name: str, arguments: dict[str, Any] = dict(), id: str = (lambda: f'call_{hex[:12]}')())

name instance-attribute

Python
name: str

arguments class-attribute instance-attribute

Python
arguments: dict[str, Any] = field(default_factory=dict)

id class-attribute instance-attribute

Python
id: str = field(default_factory=lambda: f'call_{hex[:12]}')

ToolGuardPort

Bases: Protocol

Authorizes a tool invocation (adapter delegates to ai-authz).

authorize async

Python
authorize(ctx: GovernanceContext, *, tool_name: str) -> GuardVerdict
Source code in apogee_ai/domain/services/i_governance.py
Python
async def authorize(self, ctx: GovernanceContext, *, tool_name: str) -> GuardVerdict:
    ...

ToolResult dataclass

Python
ToolResult(call_id: str, name: str, output: str, is_error: bool = False)

call_id instance-attribute

Python
call_id: str

name instance-attribute

Python
name: str

output instance-attribute

Python
output: str

is_error class-attribute instance-attribute

Python
is_error: bool = False

ToolSchema dataclass

Python
ToolSchema(name: str, description: str, parameters: dict = dict())

name instance-attribute

Python
name: str

description instance-attribute

Python
description: str

parameters class-attribute instance-attribute

Python
parameters: dict = field(default_factory=dict)

TraceStep dataclass

Python
TraceStep(kind: str, name: str, started_at: datetime = (lambda: now(utc))(), duration_ms: int = 0, input: dict[str, Any] = dict(), output: dict[str, Any] = dict(), is_error: bool = False)

kind instance-attribute

Python
kind: str

name instance-attribute

Python
name: str

started_at class-attribute instance-attribute

Python
started_at: datetime = field(default_factory=lambda: now(utc))

duration_ms class-attribute instance-attribute

Python
duration_ms: int = 0

input class-attribute instance-attribute

Python
input: dict[str, Any] = field(default_factory=dict)

output class-attribute instance-attribute

Python
output: dict[str, Any] = field(default_factory=dict)

is_error class-attribute instance-attribute

Python
is_error: bool = False

TriggerSpec dataclass

Python
TriggerSpec(type: TriggerTypeEnum = MANUAL, cron: str | None = None, webhook_path: str | None = None, event_topic: str | None = None, payload_template: str = '', metadata: dict = dict())

type class-attribute instance-attribute

Python
type: TriggerTypeEnum = MANUAL

cron class-attribute instance-attribute

Python
cron: str | None = None

webhook_path class-attribute instance-attribute

Python
webhook_path: str | None = None

event_topic class-attribute instance-attribute

Python
event_topic: str | None = None

payload_template class-attribute instance-attribute

Python
payload_template: str = ''

metadata class-attribute instance-attribute

Python
metadata: dict = field(default_factory=dict)

WorkerInput dataclass

Python
WorkerInput(instruction: str, context_messages: list[Message] = list(), metadata: dict[str, Any] = dict())

instruction instance-attribute

Python
instruction: str

context_messages class-attribute instance-attribute

Python
context_messages: list[Message] = field(default_factory=list)

metadata class-attribute instance-attribute

Python
metadata: dict[str, Any] = field(default_factory=dict)

WorkerResult dataclass

Python
WorkerResult(worker_slug: str, output: str, metadata: dict[str, Any] = dict())

worker_slug instance-attribute

Python
worker_slug: str

output instance-attribute

Python
output: str

metadata class-attribute instance-attribute

Python
metadata: dict[str, Any] = field(default_factory=dict)

Other · DTOs

AgentOutputDTO

Bases: BaseModel

id instance-attribute

Python
id: str

name instance-attribute

Python
name: str

slug instance-attribute

Python
slug: str

version instance-attribute

Python
version: str

description instance-attribute

Python
description: str

status instance-attribute

Python
status: AgentStatusEnum

agent_type instance-attribute

Python
agent_type: AgentTypeEnum

execution_pattern instance-attribute

Python
execution_pattern: ExecutionPatternEnum

engine_kind instance-attribute

Python
engine_kind: EngineKindEnum

llm_provider instance-attribute

Python
llm_provider: LLMProviderEnum

llm_model instance-attribute

Python
llm_model: str

tags instance-attribute

Python
tags: list[str]

CreateAgentDTO

Bases: BaseModel

name instance-attribute

Python
name: str

slug instance-attribute

Python
slug: str

description class-attribute instance-attribute

Python
description: str = ''

agent_type class-attribute instance-attribute

Python
agent_type: AgentTypeEnum = WORKER

execution_pattern class-attribute instance-attribute

Python
execution_pattern: ExecutionPatternEnum = REACT

engine_kind class-attribute instance-attribute

Python
engine_kind: EngineKindEnum = NATIVE

llm_provider class-attribute instance-attribute

Python
llm_provider: LLMProviderEnum = ECHO

llm_model class-attribute instance-attribute

Python
llm_model: str = 'echo'

system_prompt class-attribute instance-attribute

Python
system_prompt: str = 'You are a helpful assistant.'

tags class-attribute instance-attribute

Python
tags: list[str] = Field(default_factory=list)

ExecuteAgentInputDTO

Bases: BaseModel

slug instance-attribute

Python
slug: str

input instance-attribute

Python
input: str

history class-attribute instance-attribute

Python
history: list[dict] = Field(default_factory=list)

metadata class-attribute instance-attribute

Python
metadata: dict = Field(default_factory=dict)

ExecuteAgentOutputDTO

Bases: BaseModel

final_response instance-attribute

Python
final_response: str

iterations class-attribute instance-attribute

Python
iterations: int = 0

finish_reason class-attribute instance-attribute

Python
finish_reason: str = 'stop'

metadata class-attribute instance-attribute

Python
metadata: dict = Field(default_factory=dict)

UpdateAgentDTO

Bases: BaseModel

name class-attribute instance-attribute

Python
name: str | None = None

description class-attribute instance-attribute

Python
description: str | None = None

system_prompt class-attribute instance-attribute

Python
system_prompt: str | None = None

status class-attribute instance-attribute

Python
status: AgentStatusEnum | None = None

tags class-attribute instance-attribute

Python
tags: list[str] | None = None

Other · Enums

AgentStatusEnum

Bases: str, Enum

DRAFT class-attribute instance-attribute

Python
DRAFT = 'draft'

ACTIVE class-attribute instance-attribute

Python
ACTIVE = 'active'

ARCHIVED class-attribute instance-attribute

Python
ARCHIVED = 'archived'

AgentTypeEnum

Bases: str, Enum

SUPERVISOR class-attribute instance-attribute

Python
SUPERVISOR = 'supervisor'

ROUTER class-attribute instance-attribute

Python
ROUTER = 'router'

WORKER class-attribute instance-attribute

Python
WORKER = 'worker'

PLANNER class-attribute instance-attribute

Python
PLANNER = 'planner'

EXECUTOR class-attribute instance-attribute

Python
EXECUTOR = 'executor'

CRITIC class-attribute instance-attribute

Python
CRITIC = 'critic'

REFLECTOR class-attribute instance-attribute

Python
REFLECTOR = 'reflector'

VALIDATOR class-attribute instance-attribute

Python
VALIDATOR = 'validator'

AGGREGATOR class-attribute instance-attribute

Python
AGGREGATOR = 'aggregator'

AgentVisibilityEnum

Bases: str, Enum

PUBLIC class-attribute instance-attribute

Python
PUBLIC = 'public'

PRIVATE class-attribute instance-attribute

Python
PRIVATE = 'private'

TEAM class-attribute instance-attribute

Python
TEAM = 'team'

CollaborationPatternEnum

Bases: str, Enum

HIERARCHICAL class-attribute instance-attribute

Python
HIERARCHICAL = 'hierarchical'

SEQUENTIAL class-attribute instance-attribute

Python
SEQUENTIAL = 'sequential'

PARALLEL class-attribute instance-attribute

Python
PARALLEL = 'parallel'

MESH class-attribute instance-attribute

Python
MESH = 'mesh'

ROUND_ROBIN class-attribute instance-attribute

Python
ROUND_ROBIN = 'round_robin'

DEBATE class-attribute instance-attribute

Python
DEBATE = 'debate'

EngineKindEnum

Bases: str, Enum

NATIVE class-attribute instance-attribute

Python
NATIVE = 'native'

LANGCHAIN class-attribute instance-attribute

Python
LANGCHAIN = 'langchain'

LANGGRAPH class-attribute instance-attribute

Python
LANGGRAPH = 'langgraph'

CREWAI class-attribute instance-attribute

Python
CREWAI = 'crewai'

AUTOGEN class-attribute instance-attribute

Python
AUTOGEN = 'autogen'

AGNO class-attribute instance-attribute

Python
AGNO = 'agno'

CLAUDE_SDK class-attribute instance-attribute

Python
CLAUDE_SDK = 'claude_sdk'

OPENAI_SDK class-attribute instance-attribute

Python
OPENAI_SDK = 'openai_sdk'

GOOGLE_ADK class-attribute instance-attribute

Python
GOOGLE_ADK = 'google_adk'

MICROSOFT_AF class-attribute instance-attribute

Python
MICROSOFT_AF = 'microsoft_af'

LLAMAINDEX class-attribute instance-attribute

Python
LLAMAINDEX = 'llamaindex'

SEMANTIC_KERNEL class-attribute instance-attribute

Python
SEMANTIC_KERNEL = 'semantic_kernel'

PYDANTIC_AI class-attribute instance-attribute

Python
PYDANTIC_AI = 'pydantic_ai'

STRANDS class-attribute instance-attribute

Python
STRANDS = 'strands'

ExecutionPatternEnum

Bases: str, Enum

REACT class-attribute instance-attribute

Python
REACT = 'react'

PLAN_EXECUTE class-attribute instance-attribute

Python
PLAN_EXECUTE = 'plan_execute'

REFLEXION class-attribute instance-attribute

Python
REFLEXION = 'reflexion'

TOT class-attribute instance-attribute

Python
TOT = 'tot'

COT class-attribute instance-attribute

Python
COT = 'cot'

CONVERSATIONAL class-attribute instance-attribute

Python
CONVERSATIONAL = 'conversational'

AUTONOMOUS class-attribute instance-attribute

Python
AUTONOMOUS = 'autonomous'

LLMProviderEnum

Bases: str, Enum

ANTHROPIC class-attribute instance-attribute

Python
ANTHROPIC = 'anthropic'

OPENAI class-attribute instance-attribute

Python
OPENAI = 'openai'

GOOGLE class-attribute instance-attribute

Python
GOOGLE = 'google'

BEDROCK class-attribute instance-attribute

Python
BEDROCK = 'bedrock'

AZURE_OPENAI class-attribute instance-attribute

Python
AZURE_OPENAI = 'azure_openai'

OPENROUTER class-attribute instance-attribute

Python
OPENROUTER = 'openrouter'

OLLAMA class-attribute instance-attribute

Python
OLLAMA = 'ollama'

GROQ class-attribute instance-attribute

Python
GROQ = 'groq'

VLLM class-attribute instance-attribute

Python
VLLM = 'vllm'

AI_PROVIDER class-attribute instance-attribute

Python
AI_PROVIDER = 'ai_provider'

ECHO class-attribute instance-attribute

Python
ECHO = 'echo'

MemoryStrategyEnum

Bases: str, Enum

NONE class-attribute instance-attribute

Python
NONE = 'none'

SLIDING_WINDOW class-attribute instance-attribute

Python
SLIDING_WINDOW = 'sliding_window'

SUMMARY class-attribute instance-attribute

Python
SUMMARY = 'summary'

HYBRID class-attribute instance-attribute

Python
HYBRID = 'hybrid'

RetrievalStrategyEnum

Bases: str, Enum

SIMILARITY class-attribute instance-attribute

Python
SIMILARITY = 'similarity'

MMR class-attribute instance-attribute

Python
MMR = 'mmr'

HYBRID class-attribute instance-attribute

Python
HYBRID = 'hybrid'

RoleEnum

Bases: str, Enum

SYSTEM class-attribute instance-attribute

Python
SYSTEM = 'system'

USER class-attribute instance-attribute

Python
USER = 'user'

ASSISTANT class-attribute instance-attribute

Python
ASSISTANT = 'assistant'

TOOL class-attribute instance-attribute

Python
TOOL = 'tool'

ToolChoiceEnum

Bases: str, Enum

AUTO class-attribute instance-attribute

Python
AUTO = 'auto'

REQUIRED class-attribute instance-attribute

Python
REQUIRED = 'required'

NONE class-attribute instance-attribute

Python
NONE = 'none'

SPECIFIC class-attribute instance-attribute

Python
SPECIFIC = 'specific'

TriggerTypeEnum

Bases: str, Enum

MANUAL class-attribute instance-attribute

Python
MANUAL = 'manual'

SCHEDULED class-attribute instance-attribute

Python
SCHEDULED = 'scheduled'

WEBHOOK class-attribute instance-attribute

Python
WEBHOOK = 'webhook'

EVENT class-attribute instance-attribute

Python
EVENT = 'event'

Other · Exceptions

AgentAlreadyExistsException

Python
AgentAlreadyExistsException(identifier: str)

Bases: AlreadyExistsException

Source code in apogee_ai/domain/exceptions/agent_exceptions.py
Python
def __init__(self, identifier: str) -> None:
    super().__init__("Agent", identifier)

AgentNotFoundException

Python
AgentNotFoundException(identifier: str)

Bases: NotFoundException

Source code in apogee_ai/domain/exceptions/agent_exceptions.py
Python
def __init__(self, identifier: str) -> None:
    super().__init__("Agent", identifier)

EngineNotSupportedException

Python
EngineNotSupportedException(message: str)

Bases: DomainException

Source code in apogee_ai/domain/exceptions/agent_exceptions.py
Python
def __init__(self, message: str) -> None:
    super().__init__(message, code="ENGINE_NOT_SUPPORTED")

GuardrailViolationException

Python
GuardrailViolationException(message: str)

Bases: DomainException

Source code in apogee_ai/domain/exceptions/agent_exceptions.py
Python
def __init__(self, message: str) -> None:
    super().__init__(message, code="GUARDRAIL_VIOLATION")

InvalidAgentConfigException

Python
InvalidAgentConfigException(message: str)

Bases: DomainException

Source code in apogee_ai/domain/exceptions/agent_exceptions.py
Python
def __init__(self, message: str) -> None:
    super().__init__(message, code="INVALID_AGENT_CONFIG")

MaxIterationsExceededException

Python
MaxIterationsExceededException(max_iterations: int)

Bases: DomainException

Source code in apogee_ai/domain/exceptions/agent_exceptions.py
Python
def __init__(self, max_iterations: int) -> None:
    super().__init__(
        f"Max iterations exceeded: {max_iterations}",
        code="MAX_ITERATIONS_EXCEEDED",
    )

ToolNotFoundException

Python
ToolNotFoundException(identifier: str)

Bases: NotFoundException

Source code in apogee_ai/domain/exceptions/agent_exceptions.py
Python
def __init__(self, identifier: str) -> None:
    super().__init__("Tool", identifier)

Other · Protocols (ports)

IAgentCommandRepository

Bases: Protocol

create async

Python
create(agent: Agent) -> Agent
Source code in apogee_ai/domain/repositories/i_agent_repository.py
Python
async def create(self, agent: Agent) -> Agent: ...

update async

Python
update(agent: Agent) -> Agent
Source code in apogee_ai/domain/repositories/i_agent_repository.py
Python
async def update(self, agent: Agent) -> Agent: ...

delete async

Python
delete(slug: str) -> bool
Source code in apogee_ai/domain/repositories/i_agent_repository.py
Python
async def delete(self, slug: str) -> bool: ...

IAgentEngine

Bases: Protocol

Contract every AI agent engine adapter must implement.

kind instance-attribute

Python
kind: str

supports

Python
supports(agent: Agent) -> bool
Source code in apogee_ai/domain/services/i_agent_engine.py
Python
def supports(self, agent: Agent) -> bool: ...

build async

Python
build(agent: Agent, deps: EngineDependencies) -> CompiledAgent
Source code in apogee_ai/domain/services/i_agent_engine.py
Python
async def build(self, agent: Agent, deps: EngineDependencies) -> CompiledAgent: ...

run async

Python
run(compiled: CompiledAgent, input: AgentInput) -> AgentOutput
Source code in apogee_ai/domain/services/i_agent_engine.py
Python
async def run(
    self,
    compiled: CompiledAgent,
    input: AgentInput,
) -> AgentOutput: ...

stream async

Python
stream(compiled: CompiledAgent, input: AgentInput) -> AsyncIterator[AgentEvent]
Source code in apogee_ai/domain/services/i_agent_engine.py
Python
async def stream(
    self,
    compiled: CompiledAgent,
    input: AgentInput,
) -> AsyncIterator[AgentEvent]: ...

shutdown async

Python
shutdown(compiled: CompiledAgent) -> None
Source code in apogee_ai/domain/services/i_agent_engine.py
Python
async def shutdown(self, compiled: CompiledAgent) -> None: ...

IAgentQueryRepository

Bases: Protocol

get_by_slug async

Python
get_by_slug(slug: str) -> Agent | None
Source code in apogee_ai/domain/repositories/i_agent_repository.py
Python
async def get_by_slug(self, slug: str) -> Agent | None: ...

list_all async

Python
list_all() -> list[Agent]
Source code in apogee_ai/domain/repositories/i_agent_repository.py
Python
async def list_all(self) -> list[Agent]: ...

exists async

Python
exists(slug: str) -> bool
Source code in apogee_ai/domain/repositories/i_agent_repository.py
Python
async def exists(self, slug: str) -> bool: ...

IConversationRepository

Bases: Protocol

get async

Python
get(conversation_id: str) -> Conversation | None
Source code in apogee_ai/domain/repositories/i_conversation_repository.py
Python
async def get(self, conversation_id: str) -> Conversation | None: ...

list_by_agent async

Python
list_by_agent(agent_slug: str) -> list[Conversation]
Source code in apogee_ai/domain/repositories/i_conversation_repository.py
Python
async def list_by_agent(self, agent_slug: str) -> list[Conversation]: ...

save async

Python
save(conversation: Conversation) -> Conversation
Source code in apogee_ai/domain/repositories/i_conversation_repository.py
Python
async def save(self, conversation: Conversation) -> Conversation: ...

delete async

Python
delete(conversation_id: str) -> bool
Source code in apogee_ai/domain/repositories/i_conversation_repository.py
Python
async def delete(self, conversation_id: str) -> bool: ...

IEmbeddingClient

Bases: Protocol

model instance-attribute

Python
model: str

embed async

Python
embed(texts: list[str]) -> list[list[float]]
Source code in apogee_ai/domain/services/i_embedding_client.py
Python
async def embed(self, texts: list[str]) -> list[list[float]]: ...

IExecutionTraceRepository

Bases: Protocol

get async

Python
get(trace_id: str) -> ExecutionTrace | None
Source code in apogee_ai/domain/repositories/i_execution_trace_repository.py
Python
async def get(self, trace_id: str) -> ExecutionTrace | None: ...

list_by_agent async

Python
list_by_agent(agent_slug: str) -> list[ExecutionTrace]
Source code in apogee_ai/domain/repositories/i_execution_trace_repository.py
Python
async def list_by_agent(self, agent_slug: str) -> list[ExecutionTrace]: ...

save async

Python
save(trace: ExecutionTrace) -> ExecutionTrace
Source code in apogee_ai/domain/repositories/i_execution_trace_repository.py
Python
async def save(self, trace: ExecutionTrace) -> ExecutionTrace: ...

IGuardrail

Bases: Protocol

name instance-attribute

Python
name: str

check_input async

Python
check_input(text: str) -> GuardrailResult
Source code in apogee_ai/domain/services/i_guardrail.py
Python
async def check_input(self, text: str) -> GuardrailResult: ...

check_output async

Python
check_output(text: str) -> GuardrailResult
Source code in apogee_ai/domain/services/i_guardrail.py
Python
async def check_output(self, text: str) -> GuardrailResult: ...

IHILApprover

Bases: Protocol

Surface used by the HIL runner to ask a human for go/no-go.

review async

Python
review(request: ApprovalRequest) -> ApprovalDecision
Source code in apogee_ai/domain/services/i_hil_approver.py
Python
async def review(self, request: ApprovalRequest) -> ApprovalDecision: ...

IHandoffProtocol

Bases: Protocol

build_input

Python
build_input(instruction: str, history: list[Message], target_worker_slug: str) -> WorkerInput
Source code in apogee_ai/domain/services/i_handoff_protocol.py
Python
def build_input(
    self,
    instruction: str,
    history: list[Message],
    target_worker_slug: str,
) -> WorkerInput: ...

parse_output

Python
parse_output(raw_output: str, source_worker_slug: str) -> WorkerResult
Source code in apogee_ai/domain/services/i_handoff_protocol.py
Python
def parse_output(self, raw_output: str, source_worker_slug: str) -> WorkerResult: ...

ILLMClient

Bases: Protocol

provider_kind instance-attribute

Python
provider_kind: str

chat async

Python
chat(request: LLMRequest) -> LLMResponse
Source code in apogee_ai/domain/services/i_llm_client.py
Python
async def chat(self, request: LLMRequest) -> LLMResponse: ...

stream async

Python
stream(request: LLMRequest) -> AsyncIterator[str]
Source code in apogee_ai/domain/services/i_llm_client.py
Python
async def stream(self, request: LLMRequest) -> AsyncIterator[str]: ...

IMemoryStore

Bases: Protocol

append async

Python
append(conversation_id: str, message: Message) -> None
Source code in apogee_ai/domain/services/i_memory_store.py
Python
async def append(self, conversation_id: str, message: Message) -> None: ...

load async

Python
load(conversation_id: str) -> list[Message]
Source code in apogee_ai/domain/services/i_memory_store.py
Python
async def load(self, conversation_id: str) -> list[Message]: ...

clear async

Python
clear(conversation_id: str) -> None
Source code in apogee_ai/domain/services/i_memory_store.py
Python
async def clear(self, conversation_id: str) -> None: ...

IObservabilityEmitter

Bases: Protocol

name instance-attribute

Python
name: str

emit_trace async

Python
emit_trace(trace: ExecutionTrace) -> None
Source code in apogee_ai/domain/services/i_observability_emitter.py
Python
async def emit_trace(self, trace: ExecutionTrace) -> None: ...

emit_metric async

Python
emit_metric(name: str, value: float, tags: dict[str, Any]) -> None
Source code in apogee_ai/domain/services/i_observability_emitter.py
Python
async def emit_metric(self, name: str, value: float, tags: dict[str, Any]) -> None: ...

emit_event async

Python
emit_event(name: str, payload: dict[str, Any]) -> None
Source code in apogee_ai/domain/services/i_observability_emitter.py
Python
async def emit_event(self, name: str, payload: dict[str, Any]) -> None: ...

IToolCommandRepository

Bases: Protocol

create async

Python
create(tool: Tool) -> Tool
Source code in apogee_ai/domain/repositories/i_tool_repository.py
Python
async def create(self, tool: Tool) -> Tool: ...

delete async

Python
delete(name: str) -> bool
Source code in apogee_ai/domain/repositories/i_tool_repository.py
Python
async def delete(self, name: str) -> bool: ...

IToolExecutor

Bases: Protocol

execute async

Python
execute(call: ToolCall) -> ToolResult
Source code in apogee_ai/domain/services/i_tool_executor.py
Python
async def execute(self, call: ToolCall) -> ToolResult: ...

is_registered

Python
is_registered(name: str) -> bool
Source code in apogee_ai/domain/services/i_tool_executor.py
Python
def is_registered(self, name: str) -> bool: ...

IToolQueryRepository

Bases: Protocol

get_by_name async

Python
get_by_name(name: str) -> Tool | None
Source code in apogee_ai/domain/repositories/i_tool_repository.py
Python
async def get_by_name(self, name: str) -> Tool | None: ...

list_all async

Python
list_all() -> list[Tool]
Source code in apogee_ai/domain/repositories/i_tool_repository.py
Python
async def list_all(self) -> list[Tool]: ...

IVectorStore

Bases: Protocol

name instance-attribute

Python
name: str

upsert async

Python
upsert(documents: list[Document]) -> int
Source code in apogee_ai/domain/services/i_vector_store.py
Python
async def upsert(self, documents: list[Document]) -> int: ...

search async

Python
search(query_embedding: list[float], top_k: int = 5, threshold: float = 0.0) -> list[RetrievedDocument]
Source code in apogee_ai/domain/services/i_vector_store.py
Python
async def search(
    self,
    query_embedding: list[float],
    top_k: int = 5,
    threshold: float = 0.0,
) -> list[RetrievedDocument]: ...

delete async

Python
delete(document_ids: list[str]) -> int
Source code in apogee_ai/domain/services/i_vector_store.py
Python
async def delete(self, document_ids: list[str]) -> int: ...

count async

Python
count() -> int
Source code in apogee_ai/domain/services/i_vector_store.py
Python
async def count(self) -> int: ...

Other · Use cases

AppendMessageUseCase

Python
AppendMessageUseCase(repo: IConversationRepository)
Source code in apogee_ai/application/use_cases/conversations/conversation_use_cases.py
Python
def __init__(self, repo: IConversationRepository) -> None:
    self._repo = repo

execute async

Python
execute(conversation_id: str, message: Message) -> Conversation
Source code in apogee_ai/application/use_cases/conversations/conversation_use_cases.py
Python
async def execute(self, conversation_id: str, message: Message) -> Conversation:
    conv = await self._repo.get(conversation_id)
    if conv is None:
        raise KeyError(f"conversation '{conversation_id}' not found")
    if conv.closed:
        raise ValueError(f"conversation '{conversation_id}' is closed")
    conv.append(message)
    return await self._repo.save(conv)

CloseConversationUseCase

Python
CloseConversationUseCase(repo: IConversationRepository)
Source code in apogee_ai/application/use_cases/conversations/conversation_use_cases.py
Python
def __init__(self, repo: IConversationRepository) -> None:
    self._repo = repo

execute async

Python
execute(conversation_id: str) -> Conversation
Source code in apogee_ai/application/use_cases/conversations/conversation_use_cases.py
Python
async def execute(self, conversation_id: str) -> Conversation:
    conv = await self._repo.get(conversation_id)
    if conv is None:
        raise KeyError(f"conversation '{conversation_id}' not found")
    conv.closed = True
    return await self._repo.save(conv)

CreateAgentUseCase

Python
CreateAgentUseCase(query_repo: IAgentQueryRepository, command_repo: IAgentCommandRepository)
Source code in apogee_ai/application/use_cases/create_agent_use_case.py
Python
def __init__(
    self,
    query_repo: IAgentQueryRepository,
    command_repo: IAgentCommandRepository,
) -> None:
    self._query_repo = query_repo
    self._command_repo = command_repo

execute async

Python
execute(dto: CreateAgentDTO) -> AgentOutputDTO
Source code in apogee_ai/application/use_cases/create_agent_use_case.py
Python
async def execute(self, dto: CreateAgentDTO) -> AgentOutputDTO:
    if await self._query_repo.exists(dto.slug):
        raise AgentAlreadyExistsException(dto.slug)
    agent = agent_from_dto(dto)
    created = await self._command_repo.create(agent)
    return agent_to_output_dto(created)

DeleteAgentUseCase

Python
DeleteAgentUseCase(query_repo: IAgentQueryRepository, command_repo: IAgentCommandRepository)
Source code in apogee_ai/application/use_cases/delete_agent_use_case.py
Python
def __init__(
    self,
    query_repo: IAgentQueryRepository,
    command_repo: IAgentCommandRepository,
) -> None:
    self._query_repo = query_repo
    self._command_repo = command_repo

execute async

Python
execute(slug: str) -> None
Source code in apogee_ai/application/use_cases/delete_agent_use_case.py
Python
async def execute(self, slug: str) -> None:
    if not await self._query_repo.exists(slug):
        raise AgentNotFoundException(slug)
    await self._command_repo.delete(slug)

ExecuteAgentUseCase

Python
ExecuteAgentUseCase(query_repo: IAgentQueryRepository, engine_resolver: Callable[[Any], IAgentEngine], llm_resolver: Callable[[Any], ILLMClient], tool_resolver: Callable[[Any], Any] | None = None, guardrail_resolver: Callable[[Any], Any] | None = None, trace_repo: Any | None = None, observability_emitter: Any | None = None)
Source code in apogee_ai/application/use_cases/execute_agent_use_case.py
Python
def __init__(
    self,
    query_repo: IAgentQueryRepository,
    engine_resolver: Callable[[Any], IAgentEngine],
    llm_resolver: Callable[[Any], ILLMClient],
    tool_resolver: Callable[[Any], Any] | None = None,
    guardrail_resolver: Callable[[Any], Any] | None = None,
    trace_repo: Any | None = None,
    observability_emitter: Any | None = None,
) -> None:
    self._query_repo = query_repo
    self._engine_resolver = engine_resolver
    self._llm_resolver = llm_resolver
    self._tool_resolver = tool_resolver
    self._guardrail_resolver = guardrail_resolver
    self._trace_repo = trace_repo
    self._emitter = observability_emitter

execute async

Source code in apogee_ai/application/use_cases/execute_agent_use_case.py
Python
async def execute(self, dto: ExecuteAgentInputDTO) -> ExecuteAgentOutputDTO:
    agent = await self._query_repo.get_by_slug(dto.slug)
    if agent is None:
        raise AgentNotFoundException(dto.slug)

    guardrails = self._guardrail_resolver(agent) if self._guardrail_resolver else None
    user_input = dto.input
    if guardrails is not None:
        input_check = await guardrails.apply_input(user_input)
        user_input = input_check.redacted_text

    engine: IAgentEngine = self._engine_resolver(agent)
    llm: ILLMClient = self._llm_resolver(agent)
    tool_exec = self._tool_resolver(agent) if self._tool_resolver else None
    deps = EngineDependencies(llm_client=llm, tool_executor=tool_exec)
    compiled = await engine.build(agent, deps)

    history = [
        Message(role=RoleEnum(m["role"]), content=m["content"])
        for m in dto.history
    ]
    agent_input = AgentInput(
        user_input=user_input,
        history=history,
        metadata=dto.metadata,
    )
    started = time.time()
    try:
        output = await engine.run(compiled, agent_input)
    finally:
        await engine.shutdown(compiled)
    duration_ms = int((time.time() - started) * 1000)

    final = output.final_response
    if guardrails is not None:
        output_check = await guardrails.apply_output(final)
        final = output_check.redacted_text

    if self._trace_repo is not None:
        trace = ExecutionTrace(
            agent_slug=agent.slug,
            user_input=dto.input,
            final_response=final,
            iterations=output.iterations,
            finish_reason=output.finish_reason,
            metadata={**output.metadata, "duration_ms": duration_ms},
        )
        trace.add_step(
            TraceStep(
                kind="agent_run",
                name=agent.slug,
                duration_ms=duration_ms,
                input={"user_input": dto.input},
                output={"final_response": final},
            )
        )
        await self._trace_repo.save(trace)
        if self._emitter is not None:
            await self._emitter.emit_trace(trace)
    elif self._emitter is not None:
        trace = ExecutionTrace(
            agent_slug=agent.slug,
            user_input=dto.input,
            final_response=final,
            iterations=output.iterations,
            finish_reason=output.finish_reason,
            metadata={**output.metadata, "duration_ms": duration_ms},
        )
        await self._emitter.emit_trace(trace)

    if self._emitter is not None:
        await self._emitter.emit_metric(
            "agent.iterations", float(output.iterations), {"agent": agent.slug}
        )
        await self._emitter.emit_metric(
            "agent.duration_ms", float(duration_ms), {"agent": agent.slug}
        )

    return ExecuteAgentOutputDTO(
        final_response=final,
        iterations=output.iterations,
        finish_reason=output.finish_reason,
        metadata=output.metadata,
    )

GetAgentUseCase

Python
GetAgentUseCase(query_repo: IAgentQueryRepository)
Source code in apogee_ai/application/use_cases/get_agent_use_case.py
Python
def __init__(self, query_repo: IAgentQueryRepository) -> None:
    self._query_repo = query_repo

execute async

Python
execute(slug: str) -> AgentOutputDTO
Source code in apogee_ai/application/use_cases/get_agent_use_case.py
Python
async def execute(self, slug: str) -> AgentOutputDTO:
    agent = await self._query_repo.get_by_slug(slug)
    if agent is None:
        raise AgentNotFoundException(slug)
    return agent_to_output_dto(agent)

IngestKnowledgeUseCase

Python
IngestKnowledgeUseCase(embedder: IEmbeddingClient, store: IVectorStore)
Source code in apogee_ai/application/use_cases/knowledge/knowledge_use_cases.py
Python
def __init__(
    self, embedder: IEmbeddingClient, store: IVectorStore
) -> None:
    self._embedder = embedder
    self._store = store

execute async

Python
execute(req: IngestRequest) -> int
Source code in apogee_ai/application/use_cases/knowledge/knowledge_use_cases.py
Python
async def execute(self, req: IngestRequest) -> int:
    embeddings = await self._embedder.embed(req.texts)
    metas = req.metadatas or [{} for _ in req.texts]
    if len(metas) != len(req.texts):
        raise ValueError("metadatas length must match texts length")
    docs = [
        Document(text=t, metadata=m, embedding=e)
        for t, m, e in zip(req.texts, metas, embeddings)
    ]
    return await self._store.upsert(docs)

ListAgentsUseCase

Python
ListAgentsUseCase(query_repo: IAgentQueryRepository)
Source code in apogee_ai/application/use_cases/list_agents_use_case.py
Python
def __init__(self, query_repo: IAgentQueryRepository) -> None:
    self._query_repo = query_repo

execute async

Python
execute() -> list[AgentOutputDTO]
Source code in apogee_ai/application/use_cases/list_agents_use_case.py
Python
async def execute(self) -> list[AgentOutputDTO]:
    agents = await self._query_repo.list_all()
    return [agent_to_output_dto(a) for a in agents]

QueryKnowledgeUseCase

Python
QueryKnowledgeUseCase(embedder: IEmbeddingClient, store: IVectorStore)
Source code in apogee_ai/application/use_cases/knowledge/knowledge_use_cases.py
Python
def __init__(
    self, embedder: IEmbeddingClient, store: IVectorStore
) -> None:
    self._embedder = embedder
    self._store = store

execute async

Python
execute(query: str, top_k: int = 5, threshold: float = 0.0) -> list[RetrievedDocument]
Source code in apogee_ai/application/use_cases/knowledge/knowledge_use_cases.py
Python
async def execute(
    self, query: str, top_k: int = 5, threshold: float = 0.0
) -> list[RetrievedDocument]:
    [embedding] = await self._embedder.embed([query])
    return await self._store.search(embedding, top_k=top_k, threshold=threshold)

StartConversationUseCase

Python
StartConversationUseCase(repo: IConversationRepository)
Source code in apogee_ai/application/use_cases/conversations/conversation_use_cases.py
Python
def __init__(self, repo: IConversationRepository) -> None:
    self._repo = repo

execute async

Python
execute(agent_slug: str, user_id: str | None = None, title: str = '') -> Conversation
Source code in apogee_ai/application/use_cases/conversations/conversation_use_cases.py
Python
async def execute(
    self, agent_slug: str, user_id: str | None = None, title: str = ""
) -> Conversation:
    conv = Conversation(agent_slug=agent_slug, user_id=user_id, title=title)
    return await self._repo.save(conv)

StreamAgentUseCase

Python
StreamAgentUseCase(query_repo: IAgentQueryRepository, engine_resolver: Callable[[Agent], IAgentEngine], llm_resolver: Callable[[Agent], ILLMClient])
Source code in apogee_ai/application/use_cases/stream_agent_use_case.py
Python
def __init__(
    self,
    query_repo: IAgentQueryRepository,
    engine_resolver: Callable[[Agent], IAgentEngine],
    llm_resolver: Callable[[Agent], ILLMClient],
) -> None:
    self._repo = query_repo
    self._resolve_engine = engine_resolver
    self._resolve_llm = llm_resolver

execute async

Python
execute(dto: ExecuteAgentInputDTO) -> AsyncIterator[AgentEvent]
Source code in apogee_ai/application/use_cases/stream_agent_use_case.py
Python
async def execute(self, dto: ExecuteAgentInputDTO) -> AsyncIterator[AgentEvent]:
    agent = await self._repo.get_by_slug(dto.slug)
    if agent is None:
        raise AgentNotFoundException(slug=dto.slug)

    engine = self._resolve_engine(agent)
    deps = EngineDependencies(llm_client=self._resolve_llm(agent))
    compiled = await engine.build(agent, deps)

    async def _gen() -> AsyncIterator[AgentEvent]:
        try:
            async for event in engine.stream(
                compiled, AgentInput(user_input=dto.input)
            ):
                yield event
        finally:
            await engine.shutdown(compiled)

    return _gen()

UpdateAgentUseCase

Python
UpdateAgentUseCase(query_repo: IAgentQueryRepository, command_repo: IAgentCommandRepository)
Source code in apogee_ai/application/use_cases/update_agent_use_case.py
Python
def __init__(
    self,
    query_repo: IAgentQueryRepository,
    command_repo: IAgentCommandRepository,
) -> None:
    self._query_repo = query_repo
    self._command_repo = command_repo

execute async

Python
execute(slug: str, dto: UpdateAgentDTO) -> AgentOutputDTO
Source code in apogee_ai/application/use_cases/update_agent_use_case.py
Python
async def execute(self, slug: str, dto: UpdateAgentDTO) -> AgentOutputDTO:
    agent = await self._query_repo.get_by_slug(slug)
    if agent is None:
        raise AgentNotFoundException(slug)
    if dto.name is not None:
        agent.name = dto.name
    if dto.description is not None:
        agent.description = dto.description
    if dto.system_prompt is not None:
        agent.prompt.system = dto.system_prompt
    if dto.status is not None:
        agent.status = dto.status
    if dto.tags is not None:
        agent.tags = list(dto.tags)
    updated = await self._command_repo.update(agent)
    return agent_to_output_dto(updated)