feat(agent): add fail-open capture hooks for raw stream chunks and plan snapshots - #683
Draft
William Lyon (johnymontana) wants to merge 2 commits into
Draft
feat(agent): add fail-open capture hooks for raw stream chunks and plan snapshots#683William Lyon (johnymontana) wants to merge 2 commits into
William Lyon (johnymontana) wants to merge 2 commits into
Conversation
Ports openwiki-v0.3.3-reasoning-hooks.patch onto main @ ea80ddc: - OpenWikiRunOptions.onRawStreamChunk: lossless LangGraph stream seam, invoked before parseAgentStreamChunk inside the stream loop - OpenWikiRunOptions.onPlanSnapshot + readTemporaryPlanFile: capture the observable _plan.md before cleanup on both the error and finalize paths All hooks are fail-open; a throwing consumer never alters the OpenWiki run. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
William Lyon (johnymontana)
marked this pull request as draft
August 19, 2026 23:20
Adds OpenWikiRunOptions.recallReasoningMemory: when the host integration supplies a recall function, the agent gains a single recall_reasoning_memory tool added beside — never through — createOpenWikiConnectorTools, so the repository-mode connector gate stays intact. The tool is read-only, bounded (8k chars), capped at two recalls per run, labels results as untrusted historical data, and fails open: recall errors return an explanatory string and never alter the run. Absent the option, behavior is unchanged. Co-Authored-By: Claude Fable 5 <noreply@anthropic.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.
Motivation
External tooling (memory systems, telemetry, evaluation harnesses) cannot faithfully
observe an OpenWiki run through the public
onEventcontract: the projectedtool_endevent carries only{id, name, status}— tool outputs and error bodies aredropped — subgraph namespaces are collapsed into a
main/subgraphflag, and theagent's explicit planning artifact (
openwiki/_plan.md) is deleted on both the successand error paths before a caller can read it.
This PR adds the narrowest possible seam for lossless observation, without changing
any existing behavior.
What's added
Two optional callbacks on
OpenWikiRunOptions(+57 lines across 3 files, no newdependencies):
onRawStreamChunk?: (chunk: unknown) => void | Promise<void>— invoked insidethe stream loop before
parseAgentStreamChunkstrips fields, so consumers see theraw LangGraph
[namespace, mode, payload]tuples (tool inputs and outputs/errors,subgraph namespaces, message chunks).
onPlanSnapshot?: (plan: string) => void | Promise<void>— backed by a newreadTemporaryPlanFilehelper; captures_plan.mdimmediately before cleanup onboth the error path and the finalize path.
chatruns are unaffected (no plan file).Design constraints
debug line ("telemetry and memory capture must never change the OpenWiki run").
type docs instruct consumers to redact and bound data before persistence.
on the option.
Testing
pnpm typecheckandpnpm buildpass; the hooks are exercised end-to-end byopenwiki-graph-reasoning-memory-demo,
which builds Neo4j-backed reasoning memory and an A/B recall evaluation on top of them
(crash-safe journaling, interleaved-subagent correlation, plan-snapshot ordering).