All notable changes to papa-ts will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
- Provisional assistant message: Reverted the changes from v2.7.3 that emitted a provisional "assistant" message at the start of generation. The issue causing tools to block streaming was identified as a client-side fetch polyfill limitation, not a backend issue. The backend now behaves as it did in v2.7.2.
- Final response streaming with tools: Fixed an issue where the final response tokens would appear all at once when using tools. This was caused by client UIs not receiving an initial "Assistant" message signal after tool execution. The stream now emits a provisional assistant message when text generation begins, ensuring smooth token appending.
- Real-time tool streaming:
Agent.streamTokensnow yields empty token chunks onon_tool_startandon_tool_endevents. This ensures client UIs receive immediate updates when tools are called or finish execution, rather than waiting for the final response generation.
- Tool call detection during streaming: Fixed an issue where tool calls were not being detected in stream chunks. The implementation now properly queries checkpoint state on
chain_endevents to capture tool calls and tool responses that may only be available in the checkpoint, not in individual streaming events. - Message format detection: Improved message normalization to handle LangChain messages with
typefields (e.g., "human", "ai", "tool") in addition torolefields, ensuring correct role mapping for all message formats. - Duplicate message emissions: Fixed excessive message chunk emissions by only emitting when message count increases, preventing duplicate updates during streaming.
- Message normalization fallback: Changed default role for unrecognized messages from "system" to "assistant" for more accurate fallback behavior.
- Removed raw event access: Completely removed
includeEventsoption andevent-type chunks from the streaming API. Raw LangChainStreamEventobjects are no longer exposed to clients. The API now focuses exclusively on normalized data (tokenchunks with optionalmessages, andresultchunks).
- Stream event processing: The streaming implementation now extracts and normalizes messages from stream events when available, making them accessible via
chunk.messagesin token chunks. All LangChain internals are hidden from the public API.
- Normalized messages in stream chunks:
AgentStreamChunktoken chunks now include an optionalmessages?: ThreadMessage[]field. This allows clients to use a single, consistent message format throughout the streaming lifecycle. - Automatic thread title generation: Added
Agent.generateTitle(threadId)method that automatically generates a concise title (max 5 words) for a thread based on its conversation history. The generated title is persisted to the thread store and can be used to provide better thread organization and navigation in user interfaces.
- Checkpoint and Runnable exports: Exported
BaseCheckpointSaver,Checkpoint,CheckpointMetadata,CheckpointTuple,PendingWrite,CheckpointListOptions(from@langchain/langgraph-checkpoint) andRunnableConfig(from@langchain/core/runnables). This allows consumers to implement custom checkpoint savers and better type runnable configurations.
- LangSmith Telemetry configuration: Updated
LangSmithTelemetryOptionsto accept explicitapiKey,endpoint, andprojectparameters, allowing programmatic configuration of the LangSmith client without relying solely on environment variables.
- Thread message normalization: Introduced a canonical
ThreadMessageschema and helper utilities (normalizeThreadMessages,getMessageText) that flatten LangChain constructors (chunks, tool calls, metadata) into a stable, client-friendly shape.
Agentnow emits/hydrates normalized messages everywhere (results, history, metadata previews), ensuring consistent roles/timestamps/tool-call surfaces regardless of the underlying checkpoint format.
- ThreadStore metadata-only contract:
ThreadSnapshotno longer containsmessages. All thread stores (in-memory, FS, IndexedDB, localStorage) now persist only thread metadata (threadId,title, timestamps, custom metadata). Consumers should rely on LangGraph checkpoint savers for conversation history. - Thread history API:
Agent.getThreadHistory()now returns aThreadHistoryobject that merges thread metadata with messages loaded from the configured checkpointer. Downstream code should update type references accordingly.
- LocalStorageCheckpointSaver: New
LocalStorageCheckpointSaverimplementation lets browser environments persist LangGraph checkpoints and pending writes usinglocalStorage. Exported via the public API and wired into the browser example. - Enhanced metadata helpers:
createSnapshotnow normalizes metadata/timestamps on input, simplifying upgrades from previous formats.
- Agent persistence flow: The agent now writes only metadata (last run id, model, message preview/role) to the configured
ThreadStorewhile leaving messages to the checkpoint saver. Fetching history automatically stitches checkpoint messages with stored metadata. - Thread store implementations/tests: Updated file system, IndexedDB, localStorage, and in-memory stores plus tests and examples to the metadata-only model to avoid mismatches and lost
rolefields.
- Async provider registration:
ProviderRegistry.registerProvider()anduseOpenAI()/useAnthropic()/useOllama()/useSapAICore()now return promises so they can await dynamic model discovery. Callers mustawaitthese methods before choosing models.
- Dynamic model discovery: Built-in providers now query their respective APIs (OpenAI, Anthropic, Ollama, SAP AI Core) to list available chat/embedding models instead of relying on hard-coded defaults. Override the discovery by passing explicit
chatModels/embeddingModelsif needed.
- Provider configuration surface: Extended provider options to accept API keys, base URLs, headers, API versions, and custom
fetchimplementations to support discovery across environments. - Examples/tests: Updated sample scripts, LangGraph graph, and tests to await provider registration and showcase the new behavior.
- Agent token streaming: Expose
Agent.streamTokens()so clients can display live model tokens (with optional raw events) while still receiving the finalAgentResult. - Node streaming example: Add
examples/node/streaming.ts, a runnable script that prints live tokens using the new streaming API.
- Static LangChain provider imports: Promote
@langchain/openai,@langchain/anthropic,@langchain/ollama, and@sap-ai-sdk/langchainto direct, statically imported dependencies so bundlers (including Obsidian) always include them without dynamicimport()fallbacks. - Dynamic loader removal: Drop the bespoke
dynamicImporthelper for simpler, more reliable provider initialization across runtimes.
- Tool helper re-export: Re-export LangChain's
toolhelper from the mainpapa-tsentrypoint so downstream consumers can define tools without importing@langchain/coredirectly.
- SAP AI Core embedding support: Add default embedding models and factories for SAP AI Core via
@sap-ai-sdk/langchain.
- SAP AI Core chat integration: Migrate to
AzureOpenAiChatClient/AzureOpenAiEmbeddingClientusage for a more direct and flexible integration. - Node example: Update
examples/node/tools.tsto demonstrate using SAP AI Core as the provider (withgpt-5) instead of OpenAI as the default.
- Complete architecture rewrite: The assistant backend has been rewritten from scratch to support the new v2 architecture.
- Provider management: Provider setup and configuration flow has changed; existing integrations will likely need configuration updates.
- Agentic assistant: New
Agentabstraction and agentic assistant implementation. - Improved provider registry: Centralized
ProviderRegistryfor managing OpenAI, Anthropic, Ollama, SAP AI Core and other providers. - Telemetry integrations: LangSmith and Langfuse telemetry helpers for tracing and observability.
- Better configuration handling: Enhanced model and provider configuration types, including support for new API keys and environment variables.
- Project structure: Source code reorganized under
src/agent,src/providers,src/memory, andsrc/telemetry. - Build output: Library is now built via
tsuptargeting both ESM and CJS with bundled type definitions. - Testing setup: Tests migrated to
vitestwith improved test utilities.
- Environment handling: More robust handling of environment variables for provider API keys.
Pre-v2 series with the original architecture and provider implementations.