Skip to content

Add long-term (OCG-backed) agent memory compilation to agentspan-server - #1314

Draft
NicholasDCole wants to merge 31 commits into
mainfrom
feature/add_memory
Draft

Add long-term (OCG-backed) agent memory compilation to agentspan-server#1314
NicholasDCole wants to merge 31 commits into
mainfrom
feature/add_memory

Conversation

@NicholasDCole

@NicholasDCole NicholasDCole commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds OCG-backed long-term memory to AgentSpan agents, with deterministic recall before execution, best-effort raw run capture after execution, and completed-run feedback plumbing. It also fixes MCP tool compilation/execution and improves agent execution observability in the OSS UI.

Ports and extends agentspan-ai/agentspan#298 for Conductor OSS.

What changed

Long-term memory and recall

  • Adds longTermMemory configuration with OCG URL, server-side credential name, agent identity, and optional user identity.
  • Compiles a root-only cg_search_memories call before the first model or sub-agent task.
  • Normalizes, bounds, and injects recalled content as explicitly untrusted supporting context.
  • Propagates root recall to compiled sub-agents without issuing duplicate child recalls.
  • Keeps recall optional so OCG failures do not fail the agent run.

MCP tool compilation and execution fixes

  • Fixes MCP config.tool_names being ignored, which previously caused a configured six-tool OCG allowlist to expose all 14 discovered tools.
  • Resolves explicit OCG tools from bundled schemas at compile time, avoiding unnecessary LIST_MCP_TOOLS calls while preserving generic discovery when no explicit list is configured.
  • Rejects unknown explicit OCG tool names instead of silently widening access.
  • Preserves credential-header placeholders while tools pass through the model and resolves them only on the executable CALL_MCP_TOOL task.
  • Stamps _agent_tool_name onto dynamic MCP tasks and preserves it through JOIN compaction, including agent-as-tool sub-workflow inputs, so results are attributed and merged back into the next model turn correctly.
  • Restricts normal model-callable OCG tools to the configured query/graph operations; memory mutation, sharing, history, and cleanup tools are not exposed.

Run capture and feedback

  • Adds a reusable OCG client with server-side credential resolution, outbound-origin validation, bounded requests, retries, and contained failures.
  • Exports raw root execution history asynchronously for completed, failed, timed-out, and terminated runs; OCG remains responsible for summarization, folding, ranking, retention, and indexing.
  • Adds GET/POST /api/agent/executions/{executionId}/feedback and completed-execution feedback controls in the UI.
  • Fails feedback closed with OCG_FEEDBACK_CONTRACT_UNAVAILABLE until OCG provides the required API-key-authenticated turn feedback contract; no guessed memory key or browser-side OCG credential is used.

Agent execution UI

  • Aggregates prompt, completion, and total tokens across the complete sub-workflow tree on the server.
  • Loads agent execution details through one /full request instead of recursively fetching children in the browser.
  • Displays semantic MCP labels such as MCP_TOOL_CG_QUERY while retaining CALL_MCP_TOOL as the underlying Conductor task type.

Compatibility and robustness

  • Adds top-level-only agent execution filtering.
  • Defaults workflow media input to an empty list, preventing null-media failures for webhook and non-media runs.
  • Adds the implementation design and OCG memory configuration documentation.

Security and failure behavior

  • Agent definitions contain credential names, never API key values.
  • OCG credentials are resolved and used only by the server.
  • Recall, capture, and feedback failures do not change the workflow result.
  • Child workflows do not independently export or duplicate the root memory lifecycle.

Verification

  • ./gradlew :conductor-agentspan:test
  • ./gradlew spotlessApply
  • pnpm test -- --run in ui-next (719 passed, 1 skipped)
  • pnpm typecheck in ui-next
  • ESLint and Prettier checks for the changed UI files
  • Live verification of aggregate token counts and semantic MCP labels in the OSS execution UI

Pull request type

  • Feature
  • Bugfix
  • Refactoring
  • Build-related change

NicholasDCole and others added 30 commits July 14, 2026 13:37
Ports the server side of agentspan-ai/agentspan#298: agents configured
with longTermMemory get compiler-inlined memory steps — pre-loop
retrieval (search HTTP -> format INLINE -> _ltm_context variable
injected as an LLM system message) and post-loop distill/save/
feedback-links tasks, plus an optional feedback_sink SIMPLE worker
task. All memory tasks are optional=true so a memory outage never
fails the agent.

Adaptations for this repo: credential headers resolve via
${workflow.secrets.NAME} (this host has no CredentialAwareHttpTask, so
the inert #{NAME} form would never resolve), no __agentspan_ctx__
forwarding, and the distill model falls back to the agent's own model
when summaryModel is unset (ModelParser.parse(null) throws).

Also ports the topLevelOnly executions-search filter and the media
input-template default that fixes the inbound-webhook NPE.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
# Conflicts:
#	agentspan/src/test/java/org/conductoross/conductor/ai/agentspan/runtime/compiler/LongTermMemoryCompilerTest.java
#	common/src/main/java/org/conductoross/conductor/common/metadata/agent/LongTermMemoryConfig.java
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