Add OCG-backed long-term agent memory (ports agentspan#298)#156
Open
NicholasDCole wants to merge 1 commit into
Open
Add OCG-backed long-term agent memory (ports agentspan#298)#156NicholasDCole wants to merge 1 commit into
NicholasDCole wants to merge 1 commit into
Conversation
Port the "OCG-backed agent memory" feature from agentspan-ai/agentspan
PR #298 to the C# SDK.
- OCGMemoryStore: synchronous MemoryStore HTTP adapter over the OCG BFF
(search / save / delete / list + feedback-link minting), with the OCG
bearer token held client-side.
- Agent params: SemanticMemory (handle), MemorySummaryModel, FeedbackSink.
- Serializer: emit longTermMemory {ocgUrl, credential, agent, user, scope,
maxResults, summaryModel} + feedbackSink {taskName} when an agent's
SemanticMemory is OCG-backed. credential is a server-resolvable secret
NAME (OCG_PUBLIC_KEY), never the raw client token.
- WorkerManager: register a {name}_feedback_sink worker so the compiled
server path can hand human good/bad capability links to FeedbackSink
out-of-band (never shown to the agent's LLM).
- Tests (xUnit) for the store adapter and serializer emission.
- Example 27_OcgMemory mirroring Python examples/118_ocg_memory.py.
Client-side pre/post-run memory hooks from Python runtime.py are not ported:
this SDK's run path is control-plane only (the server runs the agent loop),
so memory activates entirely through the serialized longTermMemory config.
The server-side compiler lives in conductor-oss/conductor (agentspan-server).
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
v1r3n
approved these changes
Jul 14, 2026
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.
Ports the SDK side of the "OCG-backed agent memory" feature from agentspan-ai/agentspan#298 to the C# SDK. The server-side compiler that consumes the wire config lives in conductor-oss/conductor (
agentspan-server:LongTermMemoryConfig.java,AgentConfig.longTermMemory/feedbackSink).What was ported
OCGMemoryStore(Conductor.AI/OCGMemory.cs) — a synchronousMemoryStoreHTTP adapter over the OCG BFF:Add→POST /api/v1/memoriesSearch→POST /api/v1/memories/search(folds the human good/bad signal into result content)Delete→DELETE /api/v1/memories/{key},ListAll→GET /api/v1/memories,Clear(fan-out)GetFeedbackLinks→POST /api/v1/memories/{key}/feedback-links(mints signed good/bad capability URLs)Authorization: Bearer <token>; the token is held client-side. Also exposesMemorySummary,FeedbackEvent,FeedbackLinks, andOCGMemory.BuildMemorySummarizer.Conductor.AI/Agent.cs, +AgentBuilderfluent methods):SemanticMemory,MemorySummaryModel,FeedbackSink(Action<FeedbackEvent>).Conductor.AI/AgentConfigSerializer.cs) — the most important piece. When an agent'sSemanticMemoryis backed by anOCGMemoryStore, emits:longTermMemory:{ocgUrl, credential, agent, user, scope, maxResults, summaryModel}—credentialis a server-resolvable secret NAME (OCG_PUBLIC_KEY), never the raw client token;summaryModelfalls back to the agent's own model.feedbackSink:{taskName: "{name}_feedback_sink"}when a feedback sink is set.Conductor.AI/WorkerManager.cs) — registers a{name}_feedback_sinkworker (analogous to the existing callback/gate workers) so the compiled server path can hand theFeedbackEvent(distilled summary + signed good/bad URLs) to the user'sFeedbackSinkfor out-of-band delivery. Best-effort. The capability URLs are never surfaced to the agent's LLM.Conductor.AI.Tests/OcgMemoryTests.cs, xUnit) — store adapter (add postsvaluenotstring_value/confidence; search folds good/bad signal; feedback-link route; non-2xx raises; blank url/agent rejected) and serializer emission (present / absent / summaryModel fallback / non-OCG store no-op).Conductor.AI.Examples/27_OcgMemorymirroring Pythonexamples/118_ocg_memory.py.What was skipped
Client-side pre/post-run memory hooks from Python
runtime.py(_apply_memory_retrieval,_maybe_save_conversation_memory,_parse_summary_output) are not ported. This SDK has no client-side agent run loop —AgentRuntime.RunAsyncis control-plane only (it serializes the agent, starts the workflow, and polls the server, which runs the LLM loop). Memory therefore activates entirely through the serializedlongTermMemoryconfig that the server-side compiler expands into pre-loop retrieval + post-loop distill/save/feedback. The corresponding runtime-hook unit tests were skipped for the same reason.C#-specific adaptations
OCGMemoryStoreaccepts an injectableHttpClientfor testing (the C# analogue of Python'shttpx.Client+MockTransport); the asyncHttpClientis driven synchronously to satisfy the syncMemoryStoreinterface.Store is OCGMemoryStore) rather than Python's duck-typed_baseattribute probe.MemoryEntryis immutable (init-only), soAddreturns the key without mutating the entry.FeedbackLinksis a typed record;MemorySummary/FeedbackEventare plain classes.Test results
dotnet test Conductor.AI.Tests— 65 passed, 0 failed, 0 skipped (9 new + 56 pre-existing). The main library and the new example both build clean.🤖 Generated with Claude Code