Skip to content

feat: Session and SessionServer for multi-turn #5

@joshrotenberg

Description

@joshrotenberg

Summary

Multi-turn session support, mirroring claude_wrapper's Session/SessionServer.

  • CodexWrapper.Session — in-process session state, threads session_id
  • CodexWrapper.SessionServer — GenServer wrapper for long-lived sessions
  • Uses codex exec resume under the hood for continuations

Session API

session = CodexWrapper.Session.new(config)
{:ok, session, result} = CodexWrapper.Session.send(session, "implement the feature")
{:ok, session, result} = CodexWrapper.Session.send(session, "now add tests")
CodexWrapper.Session.total_cost(session)

SessionServer API

{:ok, pid} = CodexWrapper.SessionServer.start_link(config: config)
{:ok, result} = CodexWrapper.SessionServer.send_message(pid, "hello")
CodexWrapper.SessionServer.total_cost(pid)
CodexWrapper.SessionServer.history(pid)

Acceptance criteria

  • Session.new/2, Session.send/3, Session.stream/3
  • Automatic session_id threading via exec resume
  • Session.total_cost/1, Session.history/1, Session.turn_count/1
  • SessionServer GenServer with start_link/1, send_message/3
  • SessionServer status functions: total_cost/1, history/1, etc.
  • Tests with mock exec

Depends on

Reference

  • claude_wrapper: lib/claude_wrapper/session.ex, lib/claude_wrapper/session_server.ex
  • codex-wrapper (Rust): ExecResumeCommand in exec.rs

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions