Skip to content

feat: add server-side session management for multi-turn conversations #37

Closed

Description

@pavelanni

Summary

Add server-side conversation state management so the A2A server can maintain message history across multiple requests without relying on the client to reconstruct context.

Motivation

DocsClaw's server is currently stateless — each A2A request is processed independently. The chat TUI works around this by prepending full conversation history as text into every request, but this approach has limits:

  • Web portal use cases (from user stories) have no persistent client to accumulate history
  • Context window waste: re-sending the entire conversation as a text blob on every turn is inefficient and hits token limits quickly
  • No session isolation: without session IDs, there's no way to maintain separate conversations for different users or tasks
  • A2A multi-turn: the A2A protocol supports taskId for continuing conversations, but DocsClaw doesn't use it

Proposed design

Session model

Session {
  ID          string
  AgentConfig string        // which agent personality
  Messages    []Message     // accumulated conversation
  CreatedAt   time.Time
  LastActive  time.Time
  TTL         time.Duration // auto-expire idle sessions
}

Storage backends (in order of implementation)

  1. In-memory (map + mutex) — sufficient for single-replica demos, zero dependencies
  2. Redis — for multi-replica deployments with shared state
  3. SQLite — for single-replica with persistence across restarts

Integration points

  • A2A executor uses taskId from the protocol to look up or create sessions
  • processMessage in serve.go retrieves session history and appends new messages
  • Session TTL prevents unbounded memory growth
  • Chat TUI can optionally switch from client-side to server-side history

Design constraints

  • Default must remain stateless (no required external dependencies)
  • Session store is opt-in via agent-config.yaml
  • Memory overhead per session must be bounded (configurable max history length)
  • Must not break existing single-turn A2A usage

Related

Activity

  1. pavelanni commented on Apr 24, 2026

    @pavelanni
    CollaboratorAuthor

    Consolidated into #5 as Phase 1 (server-side session management is a prerequisite for persistent memory).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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