Skip to content

Adopt VoltAgent behind a shared Reflect runtime seam#186

Merged
jbax1899 merged 14 commits intomainfrom
feat/voltagent-reflect-runtime-seam
Mar 18, 2026
Merged

Adopt VoltAgent behind a shared Reflect runtime seam#186
jbax1899 merged 14 commits intomainfrom
feat/voltagent-reflect-runtime-seam

Conversation

@jbax1899
Copy link
Member

@jbax1899 jbax1899 commented Mar 18, 2026

Refactors reflect to run through a new internal @footnote/agent-runtime package, with VoltAgent as the active plain-text runtime and the legacy OpenAI path retained as a search fallback. Backend remains the sole public boundary and still owns planner behavior, provenance metadata, traces, auth, and API contracts.

Also fixes provenance regressions uncovered during the cutover by:

  • guaranteeing evidence/freshness chips for retrieved responses
  • preserving visible markdown citations when OpenAI search responses omit structured citation annotations
  • updating docs, AI guidance, and DeepWiki config to match the shipped runtime architecture

Summary by CodeRabbit

  • New Features

    • Added a provider-neutral generation runtime and wired VoltAgent as the primary runtime with legacy OpenAI fallback for search requests.
  • Documentation

    • Added runtime status/decision docs and expanded runtime-boundary, governance, and commenting/JSDoc guidance.
  • Tests

    • Added unit tests covering the new runtime adapters and generation flows.
  • Chores

    • Integrated the new runtime into build, TS paths, gitignore, and CI/build orchestration.

jbax1899 added 11 commits March 17, 2026 18:47
- Emphasize the importance of clear, actionable comments for junior contributors.
- Prioritize quality of comments and JSDoc over numeric coverage targets.
- Encourage the use of plain language to improve understanding of non-obvious code.
- Codify guidelines for when to use JSDoc, focusing on exported surfaces and architectural seams.
- Correct project documentation references in AGENTS.md.
- Revise README.md to clarify the reliance on OpenAI-backed runtime.
- Enhance Discord bot context in defaults.yaml to specify the AI runtime layer.
- Adjust command execution logic to ensure Windows batch files are launched reliably using cmd.exe.
- Update argument handling for commands ending with .cmd to accommodate Windows-specific requirements.
- Introduced structured retrieval facts in response metadata, including requested and used flags, intent, and context size.
- Added functions to derive evidence and freshness scores based on citation counts for retrieved responses.
- Implemented fallback mechanisms for markdown link citations when structured annotations are absent.
- Updated tests to validate the new retrieval context and scoring logic for various scenarios.
…ime package

- Clarified the ownership of the public Reflect contract and traces by the backend, while detailing the role of `@footnote/agent-runtime` in managing the execution layer.
- Added explicit documentation for the Agent Runtime package, highlighting its significance and the current state of runtime implementations, including VoltAgent and legacy fallback.
- Updated various sections to emphasize the separation of responsibilities between backend and agent runtime, ensuring contributors understand the architecture and execution flow.
@jbax1899 jbax1899 self-assigned this Mar 18, 2026
@jbax1899 jbax1899 added the enhancement New feature or request label Mar 18, 2026
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 18, 2026

Caution

Review failed

Pull request was closed or merged during review

📝 Walkthrough

Walkthrough

Added a new package @footnote/agent-runtime that defines a framework-agnostic generation runtime (types, request/result shapes, and factory). Backend reflect handler, orchestrator, and services were refactored to consume GenerationRuntime; documentation and contributor rules expanded to describe runtime boundary and commenting guidance.

Changes

Cohort / File(s) Summary
Agent Runtime Package
packages/agent-runtime/package.json, packages/agent-runtime/tsconfig.json, packages/agent-runtime/src/index.ts, packages/agent-runtime/src/legacyOpenAiRuntime.ts, packages/agent-runtime/src/voltagentRuntime.ts
New package exposing runtime types (RuntimeMessage, GenerationRequest/Result, GenerationRuntime) and concrete adapters/factories for legacy OpenAI and VoltAgent backends; includes model/message mapping and normalization utilities.
Agent Runtime Tests
packages/agent-runtime/test/*
Unit tests for runtime factories and adapters (legacy OpenAI and VoltAgent), asserting request mapping, normalization, fallback, and model resolution.
Backend: reflect wiring & server
packages/backend/src/handlers/reflect.ts, packages/backend/src/server.ts
Reflect handler and server now accept/construct a GenerationRuntime (legacy OpenAI wrapped by VoltAgent when configured) and propagate it into orchestrator/service flows.
Backend: services & planner
packages/backend/src/services/* (openaiService.ts, reflectService.ts, reflectOrchestrator.ts, reflectPlanner.ts, reflectGenerationTypes.ts, reflectGenerationHints.ts, responseMetadataHeuristics.ts)
Refactor to use GenerationRuntime; generalize web_search → search with typed GenerationSearchRequest; adjust metadata/provenance shapes (AssistantResponseMetadata, retrieval context); add evidence/freshness scoring helpers.
Backend tests updated
packages/backend/test/*
Extensive test updates to use GenerationRuntime, verify citation extraction, retrieval-driven metadata, planner search semantics, and VoltAgent fallback behaviors.
Build, config & packaging
packages/backend/package.json, packages/backend/tsconfig.json, tsconfig.json, deploy/Dockerfile.backend, .gitignore
Added dependency and build step for @footnote/agent-runtime; TypeScript path mappings and project ref; include agent-runtime in Docker build context; ignore dist in git.
Docs & contributor rules
.codexrules, .devin/wiki.json, AGENTS.md, README.md, cursor.dictionary, cursor.rules, docs/**
Documented runtime seam and adoption of VoltAgent runtime, added guidance to keep backend as public runtime boundary, and emphasized stronger comments/JSDoc and related contributor guidance.
Prompts & misc
packages/prompts/src/defaults.yaml, scripts/start-all.cjs
Prompts updated to use generation.search and new keys (contextSize/intent/repoHints); added Windows .cmd/.bat spawn handling in start script.

Sequence Diagram

sequenceDiagram
    participant Client
    participant Handler as Reflect Handler
    participant Orchestrator as Reflect Orchestrator
    participant Runtime as GenerationRuntime
    participant Legacy as Legacy OpenAI Runtime
    participant Volt as VoltAgent Runtime

    Client->>Handler: Reflect request
    Handler->>Orchestrator: create/invoke orchestration
    Orchestrator->>Runtime: generate(GenerationRequest)

    alt fallback to legacy or search routing
        alt kind = "voltagent" and no search
            Runtime->>Legacy: delegate (fallback)
            Legacy-->>Runtime: GenerationResult
        else executor path (VoltAgent)
            Runtime->>Volt: execute generation
            Volt-->>Runtime: GenerationResult
        end
    end

    Runtime-->>Orchestrator: GenerationResult
    Orchestrator->>Handler: build metadata (retrieval context, chips) and response
    Handler-->>Client: Reflect response with metadata
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~75 minutes

Possibly related PRs

Poem

🐰 I stitched a seam in runtime thread,
Backend keeps the public spread,
VoltAgent hums, OpenAI too,
One gentle interface to woo,
Docs now brighter, comments snug — hooray, hop ahead!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title clearly and specifically describes the main architectural change: adopting VoltAgent within a new shared runtime boundary for the Reflect subsystem.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/voltagent-reflect-runtime-seam
📝 Coding Plan
  • Generate coding plan for human review comments

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Tip

CodeRabbit can suggest fixes for GitHub Check annotations.

Configure the reviews.tools.github-checks setting to adjust the time to wait for GitHub Checks to complete.

…kage files

- Added package.json and tsconfig.json for the agent-runtime package to the Docker build context.
- Included source files for the agent-runtime package in the Docker image to ensure proper functionality.
…r type safety

- Changed the type of plannerMessages to RuntimeMessage[] to ensure consistency with the expected message structure.
- Added import for RuntimeMessage from the agent-runtime package to support the new type definition.
coderabbitai[bot]

This comment was marked as resolved.

…gacy OpenAI runtime error handling

- Updated tsconfig.json to use NodeNext module and resolution for better compatibility.
- Added error handling in legacyOpenAiRuntime to throw an error when the requested model is missing.
- Introduced a new test to ensure the legacy runtime fails fast when the model is not provided.
- Updated reflect service to preserve the caller-requested model when the runtime omits one, ensuring consistent model usage.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant