feat: replace custom ContextStore with A2A-native task history#121
Open
jezekra1 wants to merge 2 commits intosdk-streaming-refactorfrom
Open
feat: replace custom ContextStore with A2A-native task history#121jezekra1 wants to merge 2 commits intosdk-streaming-refactorfrom
jezekra1 wants to merge 2 commits intosdk-streaming-refactorfrom
Conversation
…eaming support Adds a delta-based streaming protocol using JSON Patch (RFC 6902) with a custom `str_ins` operation for efficient token-by-token text delivery. Server (adk-py): - MessageAccumulator: 3-level state machine collecting string chunks, parts, and metadata into complete messages with incremental patches - Extended JSON Patch (jsonpatch_ext): str_ins operation for optimized text streaming without full-value replacement - StreamingExtensionServer/Client: extension negotiation, patch extraction, delta emission, and graceful fallback for non-streaming clients - Refactored extension base: activation lifecycle, default demand constant consolidation (DEFAULT_DEMAND_NAME), and metadata handling - RunContext: extracted shared store logic into _prepare_store_data, added store_sync for synchronous callers - New yield types: ArtifactChunk for chunked artifact streaming Client (adk-ts / adk-ui): - TypeScript streaming extension types and Zod schemas - UI patch application (streaming.ts): JSON pointer resolution, replace/add/str_ins ops with optimized cloning (skip structuredClone for primitives) - Client streaming integration: draft accumulation, patch extraction from status update metadata, replace-mode emission - Fix: text duplication on final message — detect active streaming session and emit with replace flag to prevent appending duplicate content - Batched React state updates in AgentRunProvider to reduce re-renders during streaming - Removed dead commented-out proxy header code from adk-client Tests: - Unit tests for MessageAccumulator state machine - Unit tests for extended JSON Patch operations - Unit tests for RunContext store methods - E2E streaming tests: patch application, message reconstruction, client fallback behavior - Updated yield tests for new artifact chunking Assisted-By: Claude (Anthropic AI) <noreply@anthropic.com> Signed-off-by: Radek Ježek <radek.jezek@ibm.com>
Use A2A Tasks as the single source of truth for conversation history,
eliminating the duplicate ContextStore abstraction.
adk-server:
- Implement on_list_tasks in A2A proxy (forwards to agent transport)
- Remove context history endpoints (POST/GET/DELETE /contexts/{id}/history)
- Remove title generation job and worker
- Remove history-related service, repository, and schema code
adk-py:
- Delete ContextStore, InMemoryContextStore, PlatformContextStore
- Rewire RunContext to use TaskStore (load_history reads from task store)
- Remove store(), store_sync(), delete_history_from_id() from RunContext
- Remove context_store parameter from create_app() and Server.serve()
- Remove ContextHistoryItem and history methods from platform SDK
adk-ui:
- Add listTasks to A2A JSON-RPC client
- Create fetchTasksForContext for server-side task fetching
- Add convertTasksToUIMessages for task-to-UI conversion
- Rewire AgentRun/PlatformContextProvider/MessagesProvider to use tasks
- Remove useListContextHistory, context history API functions and types
Closes #116
Assisted-By: Claude (Anthropic AI) <noreply@anthropic.com>
Signed-off-by: Radek Ježek <radek.jezek@ibm.com>
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
ContextStoreabstraction with A2A's nativeTaskStoreas the single source of truth for conversation historyon_list_tasksin the A2A proxy so the UI can fetch history viaListTasksJSON-RPC/contexts/{id}/historyREST endpointThis is a breaking change — the
context_storeparameter,context.store(), and/contexts/historyendpoints are all removed.Closes #116
Changes by layer
adk-server
on_list_tasksinProxyRequestHandler(forwards to agent transport)POST/GET/DELETE /contexts/{id}/history)adk-py
ContextStore,InMemoryContextStore,PlatformContextStoreRunContextto useTaskStore—load_history()now reads fromtask_store.get(task_id)store(),store_sync(),delete_history_from_id()fromRunContextcontext_storeparameter fromcreate_app()andServer.serve()ContextHistoryItemand history methods from platform SDKcontext.store()callsadk-ui
listTasksto A2A JSON-RPC clientfetchTasksForContextfor server-side RSC task fetchingconvertTasksToUIMessagesfor task→UI message conversionAgentRun→PlatformContextProvider→MessagesProviderto use tasksuseListContextHistoryhook and context history API codeTest plan
mise run checkpasses (linting, type checking, doc snippets)ListTasksload_history)