feat: add persistence, extended thinking, and observability#22
Open
feat: add persistence, extended thinking, and observability#22
Conversation
Add ThinkingContent type to represent extended thinking blocks from LLM providers. Includes an opaque Signature field required for multi-turn round-trips with providers that support thinking (e.g. Anthropic).
Add ThinkingStartDelta, ThinkingContentDelta, and ThinkingEndDelta types to support streaming extended thinking blocks from LLM providers. These deltas complete the delta type hierarchy used for event streaming.
Update DefaultAggregator to accumulate thinking deltas into complete ThinkingContent blocks. Track thinking state alongside existing text and tool state machine.
Update Replay function to reconstruct thinking deltas when replaying AssistantMessages containing ThinkingContent blocks. Maintains message history semantics for consumers.
Implement extended thinking support in Anthropic adapter. Add WithThinking option to enable thinking with token budget. Parse thinking deltas from stream and preserve thinking signature for multi-turn conversations.
Implement metrics collection using OpenTelemetry. Track token usage, tool execution duration, LLM call duration, and agent invocation duration. Provides observability hooks for production deployments.
Implement agent store backed by PostgreSQL with pgx. Persists nodes, branches, checkpoints, and embeddings. Includes SQL schemas for tree nodes with parent-child relationships, branching state, and conversation checkpoints.
Implement tree serialization for persistence and transmission. Converts between in-memory tree structure and wire format compatible with storage backends.
Add FromStore constructor to rebuild Tree instances from persisted data. Reconstructs node maps, parent-child relationships, branches, and checkpoints from loaded data.
Change version from const to var initialized to 'dev'. Enables setting version via -ldflags at build time for release binaries.
Update delta type tests to account for three new thinking delta types. Verify all 17 delta types satisfy the Delta interface.
Update go.mod with OpenTelemetry metric, trace, and core dependencies. Add transitive dependencies for observability instrumentation.
Document extended thinking support in message table. Add note on Anthropic lacking embedding API and guide users to supply separate embedder from another provider. Update delta table to include three thinking delta types.
Add PostgreSQL migration template with node tree structure, branch tracking, and checkpoint tables. Supports hierarchical conversation storage with pgvector embeddings.
Expand llms.txt description to cover new features: extended thinking, conversation tree branching, tree serialization, structured output, provider resilience, and evaluation framework. Update key files index to reflect new agent/tree and eval packages.
Add compiled saige CLI executable.
Add nolint:gosec comments to version type conversions in the pgstore node module. The version values are guaranteed to fit within int64 range (stored in DB as int64, always non-negative), so these security linting warnings can be safely suppressed.
Tighten file permissions for created directories and JSON files to reduce unnecessary access (0o755 -> 0o750, 0o644 -> 0o600). Additionally, sanitize file paths before reading with filepath.Clean to prevent directory traversal attacks.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
ThinkingContenttype, thinking deltas for streaming, aggregator handling, message history replay, and Anthropic provider integrationpgstorepackage with node, branch, and checkpoint storage backed by SQL queries and schema migrationsSerializeandFromStorefor tree persistence and reconstructionTest plan
delta_test.gofor updated type countsaigebinary