flyte.ai.agents
flyte.ai.agents — Agent abstractions for Flyte apps.
Directory
Classes
| Class | Description |
|---|---|
Agent |
A flyte-native tool-use agent harness. |
AgentEvent |
Lightweight event emitted by the agent loop. |
AgentResult |
Outcome of a single agent invocation. |
AgentTool |
A normalized tool descriptor used by :class:Agent. |
CodeModeAgent |
Generates code via an LLM, executes it in a Monty sandbox, and. |
LLMMessage |
Provider-agnostic shape returned by :data:LLMCallable. |
MCPServerSpec |
Declarative spec for a remote MCP server that exposes tools. |
MemoryMeta |
Per-file metadata sidecar (sha256, actor, timestamp, …) for a memory entry. |
MemoryStore |
Conversation transcript + path-addressed artifact memory backed by :class:`flyte. |
Protocols
| Protocol | Description |
|---|---|
AgentProtocol |
Minimal protocol that any agent must satisfy to work with. |
Errors
| Exception | Description |
|---|---|
AccessDenied |
Raised when a write targets a read-only or reserved prefix. |
ConcurrencyError |
Raised when an expected_sha precondition does not match the current state. |
MemoryStoreError |
Base class for :class:MemoryStore errors. |
Methods
| Method | Description |
|---|---|
tool() |
Wrap a task, ``@flyte. |
Variables
| Property | Type | Description |
|---|---|---|
agent_progress_cb |
ContextVar |
Methods
tool()
def tool(
obj: Any,
name: str | None,
description: str | None,
requires_approval: bool,
) -> AgentTool | Callable[[Any], AgentTool]Wrap a task, @flyte.trace helper, plain callable, or LazyEntity as an :class:AgentTool.
This removes the boilerplate of building an :class:AgentTool by hand
(manually pulling the docstring, JSON schema, and writing a dict-args
execution bridge) when you only need to tweak how a tool is presented to
the model or gate it behind human approval.
Use it as a direct call::
refund_tool = tool(issue_refund, requires_approval=True)
or as a (parametrized) decorator stacked on top of @env.task /
@flyte.trace / a plain function::
@tool(requires_approval=True)
@env.task
async def issue_refund(order_id: str, amount_usd: float) -> dict: ...
@tool
def search(query: str) -> str: ...
The wrapped task is still registered with its :class:~flyte.TaskEnvironment
and executes on-cluster via task.aio when the agent calls it.
| Parameter | Type | Description |
|---|---|---|
obj |
Any |
The object to wrap. Omit when using tool as a parametrized decorator (@tool(...)). |
name |
str | None |
Override the tool name shown to the model. Defaults to the function / task name. |
description |
str | None |
Override the description shown to the model. Defaults to the first paragraph of the object’s docstring. |
requires_approval |
bool |
Gate execution behind the agent’s HITL approval callback. |
Returns: An :class:AgentTool (direct call) or a decorator returning one.