Condukt.Session (Condukt v0.16.5)

Copy Markdown View Source

GenServer that manages an agent session.

The session maintains:

  • Conversation history (messages)
  • Current model configuration
  • Available tools
  • Streaming state

The Agent Loop

When a prompt is received:

  1. Add user message to history
  2. Call LLM with system prompt, messages, and tools
  3. If LLM returns tool calls:
    • Execute each tool
    • Add tool results to history
    • Go to step 2
  4. If LLM returns text only, return response

Summary

Functions

Aborts the current operation.

Returns a specification to start this module under a supervisor.

Clears the conversation history.

Runs the configured compactor against the current message history.

Queues a follow-up message.

Returns the conversation history.

Runs a prompt synchronously, returning the final response.

Injects a steering message.

Streams a prompt, returning an enumerable of events.

Functions

abort(agent)

Aborts the current operation.

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

clear(agent)

Clears the conversation history.

compact(agent)

Runs the configured compactor against the current message history.

No-op when no compactor is configured. The compacted snapshot is immediately persisted if a session store is configured.

follow_up(agent, message)

Queues a follow-up message.

history(agent)

Returns the conversation history.

run(agent, prompt, opts \\ [])

Runs a prompt synchronously, returning the final response.

steer(agent, message)

Injects a steering message.

stream(agent, prompt, opts \\ [])

Streams a prompt, returning an enumerable of events.