Skip to content

(WIP) feat: pause/resume runtime, run store, useChat#5

Open
marslavish wants to merge 6 commits intofeat/features-completefrom
feat/chat-runtime
Open

(WIP) feat: pause/resume runtime, run store, useChat#5
marslavish wants to merge 6 commits intofeat/features-completefrom
feat/chat-runtime

Conversation

@marslavish
Copy link
Copy Markdown

@marslavish marslavish commented Apr 27, 2026

Pause/Resume Agent Runtime + React Bindings

Implements the test infrastructure and pause/resume runtime defined in ROADMAP.md. The single architectural change: the agent loop becomes checkpoint-able. Tools may declare a decision JSON Schema; when the loop hits one, it persists run state, emits a tool_decision_pending event, and waits for agent.resume(runId, decision) before continuing.

Phase 0 — Test Infrastructure (must)

  • 0.1 Test conventions — deterministic-by-default unit tests; live tests gated behind *.live.test.ts; one env per package (jsdom only in @agentic-kit/react)
  • 0.2 Shared test helperstools/test/ with createScriptedProvider, createScriptedSSEResponse, parseSSEStream, fixtures; existing tests migrated
  • 0.4 SSE wire-format testspackages/agent/__tests__/sse.test.ts covers split chunks, multi-line data:, comments, event-type framing, mid-event abort
  • 0.3 Integration test lanetests/integration/ scaffolded; first tests land with 1.1 / 1.3 over real HTTP
  • 0.2 (cont.) runRunStoreContractTests — portable contract suite for any RunStore implementation

Phase 1 — Pause/Resume + React Bindings (must)

  • 1.1 Pausable toolsdecision schema on AgentTool; tool_decision_pending event; agent.resume(runId, decision); reuses validateSchema for the decision payload
  • 1.2 RunStoreRunStore interface + MemoryRunStore default; consumer supplies Redis / KV / DB backend in production
  • 1.3 Run serialization helpersAgentRunHandle with events(), toReadableStream(), toResponse(); canonical SSE wire format on Content-Type: text/event-stream
  • 1.4 @agentic-kit/react — new package; useChat hook with send, respondWithDecision, abort, lifecycle callbacks (onMessage, onFinish, onDecisionPending)

Phase 2 — Production Polish (should)

  • 2.1 Prompt caching APIcache?: 'short' | 'long' flag, per-provider translation (Anthropic cache_control, OpenAI native hint, Ollama silent ignore)
  • 2.2 Telemetry / middleware hooks — before/after provider call, before/after tool call, stream-event tap; transient-vs-terminal error type

Phase 3 — Optional Extensions (could)

  • 3.1 Full Ollama tool support — streaming tool-call parsing on the Ollama adapter
  • 3.2 Retry / backoff — opt-in transient retry layer with jittered exponential backoff
  • 3.3 Stream resume on disconnect — reconnect via runId, Last-Event-ID semantics
  • 3.4 Client-side tool executionruns: 'client' flag for browser-only capabilities (deferred until a real use case appears)

Out of scope

See ROADMAP.md § Non-Goals: conversation-history persistence, generateObject analog, schema-library coupling, framework-specific helpers, UI components, embeddings as primary capability, prompt-construction utilities, conversation modes, production storage backends.

Open questions

  • Run record schema versioning (compatibility surface once RunStore ships)
  • runRunStoreContractTests coverage for discriminated-union / oneOf decision schemas
  • agent_resume event vs. redocumenting agent_start as "loop entry"
  • SSE vs. NDJSON default
  • useChat auto-routing on respondWithDecision
  • Live test policy for paid providers (Anthropic / OpenAI credits)

See ROADMAP.md § Open Questions.

@marslavish marslavish changed the base branch from main to feat/features-complete April 27, 2026 14:44
@marslavish marslavish changed the title feat: chat runtime foundation — pausable tools and test infra (WIP) feat: pause/resume runtime, run store, useChat Apr 27, 2026
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