Skip to content

docs: Session API documentation#1280

Open
mattzcarey wants to merge 2 commits intomainfrom
docs/session-api-documentation
Open

docs: Session API documentation#1280
mattzcarey wants to merge 2 commits intomainfrom
docs/session-api-documentation

Conversation

@mattzcarey
Copy link
Copy Markdown
Contributor

@mattzcarey mattzcarey commented Apr 9, 2026

Summary

  • Adds clanker documentation for the experimental Session API (agents/experimental/memory/session)
  • Covers Session, SessionManager, context blocks (all 4 provider types), compaction, AI tools, search, storage schema, custom providers, and exported utilities
  • Includes a "Gotchas and Quirks" section noting 12 surprising behaviors (unused exported types, compaction overlay semantics, fork ID behavior, etc.)

Test plan

  • Review doc accuracy against source code
  • Verify code examples compile/run

Open with Devin

Comprehensive guide covering Session, SessionManager, context blocks,
compaction, AI tools, search, storage, and custom providers.
@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Apr 9, 2026

⚠️ No Changeset found

Latest commit: 324419a

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

- Remove MessageQueryOptions (exported type, never accepted by any method)
- Remove needsCompaction (redundant with compactAfter auto-compaction)
- Remove maxContextMessages builder method and field (only fed needsCompaction)
- Update docs to reflect removals
Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 2 potential issues.

View 4 additional findings in Devin Review.

Open in Devin Review

@@ -0,0 +1,785 @@
# Sessions (Experimental)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 New doc not added to index.md as required by docs/AGENTS.md

The docs/AGENTS.md rule file mandates that when adding a new doc: "Add it to index.md in the appropriate section." The new sessions.md file was created but not added to docs/index.md. This is a violation of the repository's mandatory documentation rules.

Prompt for agents
The docs/AGENTS.md file requires that new documentation files be added to docs/index.md in the appropriate section. The sessions.md file documents the Session API (experimental), which would fit under the 'AI Integration' section of docs/index.md, near the existing experimental entries like Workspace and Codemode. Add an entry like:

- [Sessions (Experimental)](./sessions.md) - Persistent conversation storage with tree-structured messages, context blocks, compaction, and search

This should go in the 'AI Integration' section of docs/index.md, around line 47-48 where the other experimental features are listed.
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Comment on lines +124 to +125
// Get all responses that share the same parent as messageId
const siblings = session.getBranches(messageId);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 getBranches documentation incorrectly describes the API as returning siblings instead of children

The documentation says getBranches(messageId) returns "all responses that share the same parent as messageId" (i.e., siblings), but the actual implementation at packages/agents/src/experimental/memory/session/providers/agent.ts:138 uses WHERE parent_id = ${messageId}, which returns children of messageId. A user following this doc who passes a child message ID expecting to get its siblings would instead get the children of that child. The variable name siblings reinforces the incorrect mental model.

Correct description

getBranches(messageId) returns all messages whose parent is messageId — i.e., all branches extending from that point. To get "sibling responses" for regeneration, you pass the parent (e.g., the user message ID), not one of the siblings.

Suggested change
// Get all responses that share the same parent as messageId
const siblings = session.getBranches(messageId);
// Get all child messages that branch from messageId (e.g. multiple responses to a user message)
const branches = session.getBranches(messageId);
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 1 new potential issue.

View 7 additional findings in Devin Review.

Open in Devin Review

export type { SkillProvider } from "./skills";
export { isSkillProvider, R2SkillProvider } from "./skills";
export type { MessageQueryOptions, SessionOptions } from "./types";
export type { SessionOptions } from "./types";
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Missing changeset for public API removal from packages/agents

AGENTS.md requires: "Changes to packages/ that affect the public API or fix bugs need a changeset." This PR removes three public API items from packages/agents/ — the MessageQueryOptions type export (packages/agents/src/experimental/memory/session/index.ts:52), the maxContextMessages() builder method, and the needsCompaction() method on SessionManager (packages/agents/src/experimental/memory/session/manager.ts) — but does not add a changeset file describing these removals. While a pending agents: patch changeset exists from PR #1278, it documents unrelated changes (lifecycle hooks, dynamic context). Users relying on these exports (however unlikely given they were dead code) would not see the removal documented in the changelog. Additionally, experimental/session-multichat/README.md:75 still references the removed .maxContextMessages(count) method.

Prompt for agents
Add a changeset file for the agents package describing the removal of MessageQueryOptions, maxContextMessages(), and needsCompaction() from the experimental session API. Run `npx changeset` and select agents with a patch bump. Also update experimental/session-multichat/README.md line 75 to remove the reference to the now-deleted .maxContextMessages(count) builder method.
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant