Skip to content

refactor(openrouter): extract determineFallbackFeature helper#3088

Merged
chrarnoldus merged 2 commits intomainfrom
extract-fallback-feature-function
May 7, 2026
Merged

refactor(openrouter): extract determineFallbackFeature helper#3088
chrarnoldus merged 2 commits intomainfrom
extract-fallback-feature-function

Conversation

@kilo-code-bot
Copy link
Copy Markdown
Contributor

@kilo-code-bot kilo-code-bot Bot commented May 7, 2026

Summary

  • Extracts a determineFallbackFeature helper in apps/web/src/app/api/openrouter/[...path]/route.ts that decides the fallback value used when no x-kilocode-feature header is provided.
  • Drops the legacy /openrouter path check: the URL no longer influences fallback selection.
  • The helper returns 'direct-gateway' only when the system prompt does not contain either You are Kilo or You are a personal assistant running inside OpenClaw; otherwise it returns '' so validateFeatureHeader resolves to null.

Verification

N/A (no manual verification performed; no long-running checks run per instructions).

Visual Changes

N/A

Reviewer Notes

  • The system-prompt check relies on the 100-char system_prompt_prefix produced by extractPromptInfo. Both marker strings fit comfortably within that prefix, so the check is equivalent to scanning the full system prompt for these well-known opening phrases.
  • extractPromptInfo is called twice on this hot path now (once here, once downstream at line ~440). If that becomes a concern we can thread the result through instead.

Replace the legacy /openrouter path check with a system-prompt-based
fallback: only default to 'direct-gateway' when the system prompt does
not contain the Kilo or OpenClaw markers.
@kilo-code-bot
Copy link
Copy Markdown
Contributor Author

kilo-code-bot Bot commented May 7, 2026

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Files Reviewed (1 files)
  • apps/web/src/app/api/openrouter/[...path]/route.ts

Reviewed by gpt-5.5-20260423 · 190,979 tokens

@chrarnoldus
Copy link
Copy Markdown
Contributor

I see some "You are a personal assistant running inside OpenClaw" and "You are Kilo" as direct-gateway

@chrarnoldus chrarnoldus merged commit e7f8512 into main May 7, 2026
13 checks passed
@chrarnoldus chrarnoldus deleted the extract-fallback-feature-function branch May 7, 2026 09:10
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.

2 participants