create_agent#

Start here to create, run, and stream an application client. See the guide.

async zett_agent.client.create_agent(model, *, config=None, system_prompt='You are a helpful assistant.', tools=(), extensions=None, reasoning_effort=ReasoningEffort.MEDIUM, parallel_tool_call=True, max_iterations=36, max_internal_messages=8, event_dispatcher=None)[源代码]#

Create an initialized runtime wrapped in an event-aware AgentClient.

Omit config for a new UUIDv7 session, or pass an existing session ID to restore history through your configured persistence extension. All runtime options pass through unchanged; extensions=None keeps Agent defaults. The supplied model and extension resources remain caller-owned.

参数:
  • model (AgentModel | None) -- Default provider adapter, or None when each request supplies one.

  • config (AgentRunConfig | None) -- Stable session identity; omitted to generate a new UUIDv7 ID.

  • system_prompt (str) -- Initial instructions rebuilt before each request.

  • tools (Sequence[AgentTool]) -- Explicit typed tools available to the runtime.

  • extensions (Sequence[AgentExtension] | None) -- Lifecycle and middleware extensions. None keeps default memory and tool guidance; an explicit sequence replaces those defaults.

  • reasoning_effort (ReasoningEffort) -- Default reasoning level, overridable per request.

  • parallel_tool_call (bool) -- Allow supported providers and local tools to use parallel calls. Individual tools may explicitly require serial execution.

  • max_iterations (int) -- Maximum model calls for each user or internal message.

  • max_internal_messages (int) -- Maximum internal continuations per request.

  • event_dispatcher (AgentEventDispatcher | None) -- Optional callbacks awaited in stream order.

返回:

An initialized AgentClient wrapping an ordinary Agent.

抛出:

ValueError -- If runtime limits or extension/tool identities are invalid.

返回类型:

AgentClient

示例

Usage:

from zett_agent.events import AgentEvent
from zett_agent.dispatcher import AgentEventDispatcher
from zett_agent.client import create_agent

class ConsoleEvents(AgentEventDispatcher):
    async def on_text_delta_event(self, event: AgentEvent) -> None:
        print(event.delta, end="", flush=True)

client = await create_agent(model, event_dispatcher=ConsoleEvents())
reply = await client.run("Hello")
await client.run("Continue in the same session")