Skip to content

Implement planner-only search degradation and user signals#201

Merged
jbax1899 merged 2 commits intomainfrom
codex/pr1-search-degradation-signals
Mar 27, 2026
Merged

Implement planner-only search degradation and user signals#201
jbax1899 merged 2 commits intomainfrom
codex/pr1-search-degradation-signals

Conversation

@jbax1899
Copy link
Copy Markdown
Member

@jbax1899 jbax1899 commented Mar 27, 2026

Implements planner-only reroute/drop behavior in backend orchestration, emits originalProfileId/effectiveProfileId execution metadata, aligns structured logs, and adds user-visible “search unavailable for selected model” messaging in web and Discord.

Summary by CodeRabbit

  • New Features
    • Intelligent model fallback: when a chosen model can't perform web search, the system will switch to an available search-capable model so search-based requests still run.
    • Enhanced warnings: clear "search unavailable" notices are shown in the web UI footer and Discord responses when search is skipped.
    • Improved visibility: selection and fallback decisions are now recorded so logs reflect original vs. effective model choices.

@jbax1899 jbax1899 self-assigned this Mar 27, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 27, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 3e07cf4f-ef00-4e6f-80dc-55746143a04f

📥 Commits

Reviewing files that changed from the base of the PR and between 3e78d87 and 460048b.

📒 Files selected for processing (3)
  • packages/backend/src/services/chatOrchestrator.ts
  • packages/backend/test/chatOrchestrator.test.ts
  • packages/web/src/components/ProvenanceFooter.tsx
✅ Files skipped from review due to trivial changes (1)
  • packages/backend/src/services/chatOrchestrator.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • packages/web/src/components/ProvenanceFooter.tsx
  • packages/backend/test/chatOrchestrator.test.ts

📝 Walkthrough

Walkthrough

The PR adds profile-selection provenance (original vs effective profile IDs), conditionally reroutes planner-selected non-search-capable profiles to enabled search-capable fallbacks, emits structured warnings and telemetry about reroutes, and surfaces search-unavailability warnings to clients (Discord/web). Tests and schemas updated accordingly.

Changes

Cohort / File(s) Summary
Core Orchestration Logic
packages/backend/src/services/chatOrchestrator.ts, packages/backend/test/chatOrchestrator.test.ts
Track profileSelectionSource, derive searchCapableFallbackProfiles, apply conditional reroute only for planner-selected non-search profiles (set originalProfileId, effectiveProfileId, rerouteApplied=true) and otherwise clear request search and mark web_search skipped; tests updated for planner- and request-selected behaviors.
Execution Metadata & Service Integration
packages/backend/src/services/openaiService.ts
Add optional originalProfileId / effectiveProfileId to planner/generation executionContext and include them in emitted execution[] events when defined.
Contracts & Schemas
packages/contracts/src/ethics-core/types.ts, packages/contracts/src/web/schemas.ts, packages/contracts/test/webSchemas.test.ts
Extend ExecutionEvent type and Zod ExecutionEventSchema with optional originalProfileId and effectiveProfileId (min length 1). Test fixture updated to include new fields.
Client UI / Bots
packages/discord-bot/src/commands/chat.ts, packages/discord-bot/test/chatCommand.test.ts, packages/web/src/components/ProvenanceFooter.tsx
Detect skipped web_search with reasonCode === 'search_not_supported_by_selected_profile'; Discord bot prepends a warning prefix to messages and web provenance footer conditionally renders a "search unavailable for selected model" status; tests adjusted to expect the warning.

Sequence Diagram

sequenceDiagram
    participant Request
    participant Orchestrator as Chat Orchestrator
    participant ProfileMgr as Profile Manager / Catalog
    participant Fallback as Fallback Selector
    participant Executor as Execution/Telemetry
    participant Client

    Request->>Orchestrator: Receive chat request (may include profile)
    Orchestrator->>Orchestrator: Determine profileSelectionSource (request/planner/default)
    Orchestrator->>ProfileMgr: Fetch selected profile capabilities (canUseSearch?)
    alt Planner-selected profile lacks search
        ProfileMgr-->>Orchestrator: cannot use search
        Orchestrator->>Fallback: Find enabled search-capable fallback (different id)
        Fallback-->>Orchestrator: fallback profile found
        Orchestrator->>Orchestrator: Set originalProfileId, effectiveProfileId, rerouteApplied=true
        Orchestrator->>Executor: Emit reroute warning + execution context
    else Non-planner (request) selected lacks search
        ProfileMgr-->>Orchestrator: cannot use search
        Orchestrator->>Orchestrator: Clear generationForExecution.search, set toolExecutionContext:web_search skipped
        Orchestrator->>Executor: Emit skipped search warning with provenance
    end
    Orchestrator->>Executor: Persist planner/generation executionContext (include original/effective IDs)
    Executor-->>Client: Response + metadata (execution timeline)
    Client->>Client: Detect skipped-search signal in metadata
    Client-->>Client: Render warning (Discord / web footer)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested labels

enhancement

Poem

🐰 When planner picks a profile that can't explore,
I hop to a fallback and search a bit more.
I leave a trail — original and new,
So logs and UIs know which profile flew.
Hooray for reroutes and breadcrumbs in store!

🚥 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 title 'Implement planner-only search degradation and user signals' accurately and concisely summarizes the main changes: planner-only reroute logic for search and new user-facing signals for search unavailability.
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 codex/pr1-search-degradation-signals

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.

coderabbitai[bot]

This comment was marked as resolved.

…ased on profile selection source. Update tests to reflect changes in profile capabilities and ensure accurate fallback profile selection. Enhance accessibility in ProvenanceFooter by adding ARIA attributes to the warning message.
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