Skip to content

feat: planner-aware profile routing, execution timeline metadata, and Discord /chat model switching (with Ollama support)#200

Merged
jbax1899 merged 19 commits intomainfrom
feat/second-provider-and-tool-registry
Mar 27, 2026
Merged

feat: planner-aware profile routing, execution timeline metadata, and Discord /chat model switching (with Ollama support)#200
jbax1899 merged 19 commits intomainfrom
feat/second-provider-and-tool-registry

Conversation

@jbax1899
Copy link
Member

@jbax1899 jbax1899 commented Mar 27, 2026

Delivers end-to-end model-profile routing and visibility improvements across backend and Discord.
Adds structured execution timeline metadata (planner/tool/generation with status/duration).
Introduces /api/chat/profiles and slash /chat per-request profile switching.
Supports multi-guild command rollout and profile-choice fetch retries.
Extends provider config/runtime wiring for Ollama (including cloud/local handling and profile enablement rules).

This branch intentionally grouped the model-profile routing seam with /chat operator controls and execution visibility so we could validate the full request path (selection -> resolution -> execution -> surfaced metadata). This also helps close integration gaps discovered during testing (profile override precedence, provenance/footer parity, and Ollama cloud runtime wiring) before splitting follow-up hardening into later branches.

Summary by CodeRabbit

  • New Features

    • Added /chat Discord slash command with dynamic profile choices and generation hints (reasoning effort, verbosity).
    • Public API endpoint to list available chat profiles.
    • Multi-guild Discord command deployment.
    • Optional Ollama provider support (local and cloud).
  • Documentation

    • Updated environment examples to document Ollama settings and multi-guild deployment.
  • Bug Fixes & Improvements

    • Enhanced execution/timing metadata, provenance display, and more robust profile/model selection.

jbax1899 added 10 commits March 26, 2026 17:41
…provider. Update environment variables in .env.example and backend services to include Ollama-specific settings. Refactor model profile handling to accommodate Ollama profiles, ensuring proper enabling/disabling based on configuration. Add tests to validate Ollama profile behavior and integration with the runtime.
…structured execution timeline. Update chat orchestrator and service to include tool execution status and generation details in the response metadata. Refactor related tests to validate the integration of execution context, ensuring accurate logging of planner, tool, and generation events.
…execution metadata, including status and duration for planner, tool, and generation events. Update chat orchestrator and service to log orchestration timing and improve response metadata. Refactor tests to validate execution context handling and ensure accurate logging of execution details.
…s for execution context. Add clarifications on profile selection and capabilities handling, ensuring better visibility into orchestration timing and execution status. Update metadata for improved troubleshooting and UI visibility.
…api/chat/profiles to return enabled chat profile options, including descriptions. Update backend to handle chat profile requests and integrate with existing services. Enhance Discord bot commands to support profile selection, ensuring transparent user experience. Add tests for profile retrieval and command behavior, validating correct integration and error handling.
…iles. Revise descriptions for clarity and adjust maxInputTokens for several profiles. Introduce new Ollama profiles for Qwen and DeepSeek, along with a GPT-OSS profile for improved performance in general chat. Ensure all profiles are well-documented with links to relevant model documentation.
…loyment. Update environment variable handling in .env.example to include DISCORD_GUILD_IDS for comma-separated guild IDs, while maintaining DISCORD_GUILD_ID as a legacy option. Modify command deployment logic to iterate over configured guilds, ensuring explicit command rollout. Enhance runtime configuration validation and add tests for new guild ID handling.
…nce `applyChatCommandProfileChoices` to support configurable maximum attempts and retry delay. Update tests to validate retry behavior and ensure proper handling of profile fetch failures.
…ofile selection logic. Enhance logging for profile ID mismatches and clarify profile selection precedence. Update Discord bot command to include detailed response metadata and improve message formatting. Revise model profiles descriptions for clarity and consistency.
…ntroduce options for Ollama base URL, API key, and local inference settings. Implement logic to resolve provider overrides based on Ollama settings and normalize cloud base URLs. Add tests to validate Ollama provider mapping and environment variable application.
@jbax1899 jbax1899 self-assigned this Mar 27, 2026
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 27, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 2559f07c-0883-4716-8b64-53aa994de266

📥 Commits

Reviewing files that changed from the base of the PR and between 9fe9abb and b924898.

📒 Files selected for processing (1)
  • packages/backend/src/handlers/chatProfiles.ts

📝 Walkthrough

Walkthrough

Adds Ollama provider support, a GET /api/chat/profiles endpoint and client, execution-timeline metadata (planner/tool/generation), planner/orchestrator telemetry and fail-open behavior, multi-guild Discord slash-command deployment with a new /chat command and profile-choice hydration, plus related config, contracts, runtime, UI, and tests.

Changes

Cohort / File(s) Summary
Env & Config Examples
\.env\.example, packages/config-spec/src/env-spec.ts
Add OLLAMA_BASE_URL, OLLAMA_API_KEY, OLLAMA_LOCAL_INFERENCE_ENABLED; mark OPENAI_API_KEY optional; update env metadata.
Backend Config Sections & Parsers
packages/backend/src/config/sections/ollama.ts, packages/backend/src/config/buildRuntimeConfig.ts, packages/backend/src/config/types.ts, packages/backend/src/config/parsers.ts
Add Ollama section builder, wire Ollama into runtime config/types, add parseBooleanFlag, and include Ollama env values in startup diagnostics.
Model Profiles Catalog
packages/backend/src/config/model-profiles.defaults.yaml, packages/backend/src/config/sections/modelProfiles.ts
Add Ollama model profiles; compute provider availability from env and disable profiles whose provider is unavailable (emit warnings).
API Spec & Client
docs/api/openapi.yaml, packages/api-client/src/chat.ts
Add GET /api/chat/profiles endpoint spec and client method getChatProfiles with response validation.
Contracts & Schemas
packages/contracts/src/web/types.ts, packages/contracts/src/web/schemas.ts, packages/contracts/src/ethics-core/types.ts, packages/contracts/src/ethics-core/index.ts, packages/contracts/src/index.ts, packages/contracts/src/providers.ts
Add ChatProfileOption/GetChatProfilesResponse, add generation to PostChatRequest, add execution-telemetry types/schemas (ExecutionEvent, ExecutionStatus, ExecutionReasonCode), extend ResponseMetadata with totalDurationMs and execution[], and include ollama in supported providers.
Chat Profiles Handler & Routing
packages/backend/src/handlers/chatProfiles.ts, packages/backend/src/server.ts
New GET /api/chat/profiles handler returning enabled profiles (trim/truncate descriptions), method-guard (405), fail-open fallback, and server wiring.
Agent Runtime (VoltAgent)
packages/agent-runtime/src/voltagentRuntime.ts, packages/agent-runtime/test/voltagentRuntime.test.ts
Generalize provider-tool shape, add Ollama executor config and provider remapping (ollamaollama-cloud when applicable), provider-based search-tool registry, and corresponding tests.
Planner & Orchestrator
packages/backend/src/services/chatPlanner.ts, packages/backend/src/services/chatOrchestrator.ts, packages/backend/src/services/chatProfileOverlay.ts
Planner now returns execution metadata (status/reason/duration); orchestrator records timings, changes profile-resolution precedence and merges request generation overrides; overlay no longer warns on profile mismatch.
Chat Service & Metadata
packages/backend/src/services/chatService.ts, packages/backend/src/services/openaiService.ts
Measure generation duration, accept orchestration/execution context, compute/propagate totalDurationMs, and build canonical execution timeline into response metadata.
Discord Bot: Command & Wiring
packages/discord-bot/src/commands/chat.ts, packages/discord-bot/src/utils/chatCommandProfiles.ts, packages/discord-bot/src/config/runtime.ts, packages/discord-bot/src/index.ts, packages/discord-bot/src/utils/MessageProcessor.ts
Add /chat slash command (profile/reasoning/verbosity), apply backend profile choices (retries, truncate to 25), switch to DISCORD_GUILD_IDS multi-guild deployment with deduplication and per-guild deployment handling, and remove hardcoded profileId from message processor payload.
UI: Trace & Provenance
packages/web/src/components/ProvenanceFooter.tsx, packages/web/src/pages/TracePage.tsx
Render execution timeline summary and totalDurationMs in provenance/trace UI and derive model label from execution when present.
Tests
packages/backend/test/*, packages/discord-bot/test/*, packages/agent-runtime/test/*, packages/contracts/test/*
Add/adjust tests for Ollama routing, chat profiles endpoint, execution telemetry, planner failure handling, Discord /chat command behavior and profile-choice hydration, and schema validation for execution events.

Sequence Diagram(s)

sequenceDiagram
    participant User as Discord User
    participant Bot as Discord Bot
    participant Backend as Backend API
    participant Planner as Chat Planner
    participant Generation as Generation Runtime

    User->>Bot: /chat (prompt, optional profile/generation)
    Bot->>Bot: Defer reply
    Bot->>Backend: POST /api/chat (with orchestrationStartedAtMs & generation hint)
    activate Backend
    Backend->>Planner: planChat(request)
    activate Planner
    Planner-->>Backend: { plan, execution: { status, durationMs } }
    deactivate Planner
    Backend->>Backend: Resolve profile (request override or planner/default)
    Backend->>Generation: generate(request with effective profile/model)
    activate Generation
    Generation-->>Backend: message + generation metadata (model,duration)
    deactivate Generation
    Backend->>Backend: Build execution timeline (planner → tool? → generation)
    Backend-->>Bot: { action: 'message', message, metadata (execution,totalDurationMs) }
    deactivate Backend
    Bot->>User: Edit reply with message and execution summary
Loading
sequenceDiagram
    participant Env as Env
    participant Config as Runtime Config
    participant Catalog as Model Catalog Parser

    Env->>Config: buildRuntimeConfig(env)
    activate Config
    Config->>Catalog: parse default model-profiles
    activate Catalog
    Catalog-->>Config: parsedCatalog
    deactivate Catalog
    Config->>Config: compute provider availability (OPENAI_API_KEY, OLLAMA_BASE_URL, OLLAMA_LOCAL_INFERENCE_ENABLED)
    Config->>Config: disable catalog entries whose provider is unavailable
    Config-->>Env: runtimeConfig with filtered modelProfiles
    deactivate Config
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

Suggested labels

enhancement

Poem

🐰 I sniffed the Ollama breeze,
Profiles lined up like springtime trees,
Planner ticks, the runtimes play,
Commands hop out to guilds today,
Traces gleam — carrots all the way! 🥕

🚥 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 comprehensively summarizes the main changes: planner-aware profile routing (request-level profile override and planner integration), execution timeline metadata (new ExecutionEvent tracking), and Discord /chat command with model switching and Ollama provider support.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ 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/second-provider-and-tool-registry

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.

…ace mock. This change ensures that the test accurately reflects the expected behavior of the bot API when handling trace card requests.
coderabbitai[bot]

This comment was marked as resolved.

…ration options. Introduce a new type for Ollama executor configuration, refactor related logic to resolve provider settings, and update tests to validate the mapping of Ollama configurations. This improves the handling of Ollama provider settings and ensures accurate environment variable application.
…' for improved caching behavior. This change ensures that chat profile responses are not cached, enhancing data freshness for users.
…etadata mutation during trace persistence. This change ensures that the ChatService computes totalDurationMs before metadata assembly, maintaining race-free trace persistence.
… Discord bot. Track successful and failed deployments, providing detailed logs for each guild. Abort startup if all deployments fail, ensuring robust command rollout across configured guilds.
…mporary directory cleanup. Ensure that YAML file writing and model profile section building are wrapped in try-finally blocks to prevent resource leaks. This enhances test reliability and maintains proper cleanup after execution.
This new utility function interprets common boolean representations ("1", "true", "yes") for environment configuration. It has been integrated into modelProfiles and ollama sections, replacing redundant implementations. This change streamlines boolean flag handling across the codebase.
…ntime configuration. This change enhances test accuracy by ensuring the profile ID reflects the current runtime settings instead of a hardcoded value.
coderabbitai[bot]

This comment was marked as resolved.

…runcated descriptions. The change modifies the slice length to ensure proper formatting of the ellipsis, enhancing the clarity of the returned string.
@jbax1899 jbax1899 merged commit 2d28f2a into main Mar 27, 2026
5 of 6 checks passed
@jbax1899 jbax1899 deleted the feat/second-provider-and-tool-registry branch March 27, 2026 01:07
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