Sycophant.Agent
(sycophant v0.4.2)
Copy Markdown
GenStateMachine-based agent that manages LLM conversations with tool execution, callbacks, statistics tracking, and telemetry.
States
:idle- Ready to accept new messages:generating- Waiting for LLM response:streaming- Waiting for LLM response with stream forwarding:tool_executing- Executing tool calls from LLM response:error- Last request failed, recoverable:completed- Agent stopped by callback, no further requests accepted
Examples
{:ok, agent} = Sycophant.Agent.start_link("anthropic:claude-haiku-4-5-20251001")
{:ok, response} = Sycophant.Agent.chat(agent, "Hello!")
Sycophant.Agent.stop(agent)
Summary
Functions
Sends a message and waits synchronously for the response.
Sends a message asynchronously; response delivered via on_response callback.
Returns a specification to start this module under a supervisor.
Returns the current conversation context.
Starts an agent process linked to the caller.
Returns accumulated statistics for all turns.
Returns the current state of the agent.
Stops the agent process.
Types
@type agent() :: GenStateMachine.server_ref()
Functions
@spec chat( agent(), String.t() | Sycophant.Message.t() | [Sycophant.Message.t()], timeout() ) :: {:ok, Sycophant.Response.t()} | {:error, term()}
Sends a message and waits synchronously for the response.
@spec chat_async( agent(), String.t() | Sycophant.Message.t() | [Sycophant.Message.t()] ) :: :ok | {:error, term()}
Sends a message asynchronously; response delivered via on_response callback.
Returns a specification to start this module under a supervisor.
See Supervisor.
@spec context(agent()) :: Sycophant.Context.t()
Returns the current conversation context.
@spec start_link( String.t() | nil, keyword() ) :: GenStateMachine.on_start()
Starts an agent process linked to the caller.
@spec stats(agent()) :: Sycophant.Agent.Stats.t()
Returns accumulated statistics for all turns.
Returns the current state of the agent.
Stops the agent process.