Skip to content
This repository was archived by the owner on Oct 1, 2026. It is now read-only.

Add conversation summary protocol for durable history compaction (v2.2.0) - #61

Open
DidierRLopes wants to merge 3 commits into
mainfrom
feat/summary-protocol
Open

DidierRLopes wants to merge 3 commits into
mainfrom
feat/summary-protocol

Conversation

@DidierRLopes

@DidierRLopes DidierRLopes commented Jul 11, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Adds the wire protocol for durable conversation compaction: instead of agents re-summarizing long histories on every request, a generated summary becomes a first-class, persisted message that clients send back on subsequent turns, validated by a content hash.

Part of a 3-repo change (see Cross-repo context below).

Changes

  • LlmClientSummaryMessage — new message type (role: "summary", content, covered_through_message_id, source_hash, version = 1), added to the LlmMessage alias and the QueryRequest.messages union.
  • message_id: str | None — new optional field on LlmClientMessage and LlmClientFunctionCallResultMessage. Clients assign stable per-message IDs so summaries can anchor to a specific message via covered_through_message_id.
  • ConversationSummarySSE (event: copilotConversationSummary) + conversation_summary() helper — how agents deliver a freshly generated summary to the client for persistence.
  • conversation_source_hash() — canonical hash over a message sequence, used to detect stale summaries after history edits. Deliberately excludes tool-result data (clients renew expired file URLs in place between requests) and extra_state (mutates every round trip); summary messages never feed the hash.
  • testing.py: CopilotResponse parses the new event; conversation_summaries accessor.
  • README docs for the new helper + message type; version bump to 2.2.0.

Backward compatibility

Additive only. Older SDK versions will reject role: "summary" payloads (422), which is why OpenBB Workspace only sends summaries to agents that advertise the conversation-summaries feature flag in agents.json (see the terminalpro PR).

Testing

pytest tests/ -q   # 17 tests: union parsing, hash determinism/invariance/sensitivity, SSE shape

Note: the local pre-commit mypy hook runs mypy . and can trip over unrelated untracked clutter in a dirty checkout; CI runs it clean.

Cross-repo context & merge order

  1. This PR → merge → cut a GitHub Release (publishes openbb-ai 2.2.0 to PyPI).
  2. OpenBB-finance/openbb-ada#639 — server implementation (its dep pin must be bumped to ^2.2.0 + poetry lock after the release; Ada CI fails on the new imports until then).
  3. OpenBB-finance/terminalpro#2086 — client persistence (safe to merge last).

🤖 Generated with Claude Code

https://claude.ai/code/session_01TpjcdkyX1YNzGsphVEQ8kn

DidierRLopes and others added 3 commits July 10, 2026 19:48
…d, ConversationSummarySSE, conversation_source_hash

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TpjcdkyX1YNzGsphVEQ8kn
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TpjcdkyX1YNzGsphVEQ8kn
Simplifies the conversation summary protocol by removing the schema
version, source hash, and public hashing helper. Summary content and the
last covered message ID are sufficient for the supported conversation
flow, where intermediate messages are not edited, deleted, or reordered.

This reduces the public model and helper API without changing how agents
emit or receive persisted summaries.
andrewkenreich pushed a commit that referenced this pull request Aug 18, 2026
> **Stacked PR:** based on #64 (repo hygiene needed for green CI). Merge
that first — GitHub retargets this PR automatically and the diff here
contains only the feature.

Part of the cross-repo **"save this as a skill"** feature: users can ask
the copilot to save the current conversation's workflow as a reusable
skill in their Workspace skill library.

## What this PR does

- Adds `"save_skill"` to the closed `FunctionCallSSEData.function`
Literal in `openbb_ai/models.py`, allowing agents to emit a
`copilotFunctionCall` SSE that asks the Workspace client to save a
skill. This follows the exact precedent of `get_skill_content` (#52).
- Bumps the package version to **2.2.0**.

## Protocol flow enabled by this change

1. The agent (openbb-ada) yields `FunctionCallSSE(function="save_skill",
input_arguments={"name", "instructions"})` and closes the stream.
2. The Workspace frontend generates the skill from the conversation,
saves it, and re-POSTs `/query` with an
`LlmClientFunctionCallResultMessage` carrying a `ClientCommandResult`
(`{"skill": {"slug", "description"}}` on success).
3. The agent confirms the save to the user.

## ⚠️ Version note

PR #61 (durable conversation summaries) also bumps to 2.2.0. Whichever
of the two merges second must bump to 2.3.0 before release.

## Companion PRs — review/test together

This PR only extends the protocol; the behavior lives in the companion
PRs and needs all three to test end-to-end:

- openbb-ada: OpenBB-finance/openbb-ada#643
- terminalpro: OpenBB-finance/terminalpro#2106

**Release ordering:** merge + publish this package to PyPI first (ada's
`^2.1.0` caret accepts 2.2.0, but ada CI/Docker installs from PyPI, so
the ada PR's new Literal value fails validation until 2.2.0 is
published) → then openbb-ada → terminalpro can go before or alongside
ada.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

https://claude.ai/code/session_01KocxNUyBQT8K8qTduX7Gyu

---------

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants