refactor: name the runtime mode "hybrid" instead of "platform"#163
refactor: name the runtime mode "hybrid" instead of "platform"#163njbrake wants to merge 7 commits into
Conversation
WalkthroughRenames the gateway's connected-to-otari.ai runtime mode from "platform mode" to "hybrid mode" throughout the codebase. ChangesPlatform-to-hybrid mode rename
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
✨ Simplify code
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. Comment |
There was a problem hiding this comment.
Pull request overview
This PR standardizes the runtime-mode terminology by renaming the legacy “platform mode” to “connected mode” across the Otari Gateway codebase, tests, and documentation, while preserving “platform” to refer to the upstream otari.ai service and related integration surfaces.
Changes:
- Renames mode semantics and surfaces:
effective_modenow reports"connected"; health endpoints return"mode": "connected". - Updates config and runtime branching:
is_platform_mode→is_connected_mode, andOTARI_MODE=platformremains accepted as a legacy alias forconnected(with new test coverage). - Renames/updates connected-mode routing and documentation, and regenerates OpenAPI descriptions to match updated docstrings.
Reviewed changes
Copilot reviewed 38 out of 38 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/unit/test_run_platform_attempts.py | Updates unit-test docstring to “connected-mode” terminology. |
| tests/unit/test_pipeline_settlement.py | Renames context flag and parametrization to “connected”; updates related assertions. |
| tests/unit/test_mcp_loop.py | Updates comments referencing the attempt loop terminology. |
| tests/integration/test_connected_mode_surface.py | Updates integration tests to assert "mode": "connected" and connected-mode disabled endpoints. |
| tests/integration/test_connected_mode_responses.py | Updates connected-mode responses tests and their docstrings/names. |
| tests/integration/test_connected_mode_messages.py | Updates connected-mode messages tests and their docstrings/names. |
| tests/integration/test_connected_mode_chat.py | Updates connected-mode chat tests, including legacy resolve-shape coverage. |
| tests/integration/test_config_env_loading.py | Updates env/config loading expectations; adds test for legacy mode: platform alias. |
| tests/integration/test_batches_endpoint.py | Updates connected-mode batch endpoint expectations and docstrings. |
| src/gateway/services/mcp_loop.py | Updates docstring references to connected-mode attempt loop consumers. |
| src/gateway/services/mcp_loop_responses.py | Updates docstring references for connected-mode callers. |
| src/gateway/services/mcp_loop_messages.py | Updates docstring references for connected-mode callers. |
| src/gateway/main.py | Switches validation/lifespan branching to is_connected_mode and updates messages. |
| src/gateway/core/config.py | Implements "connected" as effective_mode, renames property to is_connected_mode, accepts legacy platform mode. |
| src/gateway/cli.py | Updates CLI validation/logging strings and branching to connected mode. |
| src/gateway/api/routes/responses.py | Updates connected-mode branching and explanatory comments/docstrings. |
| src/gateway/api/routes/messages.py | Updates connected-mode branching and related docstrings/comments. |
| src/gateway/api/routes/health.py | Updates health/readiness payload "mode" values to "connected". |
| src/gateway/api/routes/connected_mode.py | Updates disabled-endpoint detail text and router tag to connected-mode. |
| src/gateway/api/routes/chat.py | Updates connected-mode streaming and non-streaming path comments/branching. |
| src/gateway/api/routes/_platform.py | Updates module/docs to “connected-mode shared infrastructure” and related messages. |
| src/gateway/api/routes/_pipeline.py | Renames platform_mode flag to connected_mode across request context and tool preparation. |
| src/gateway/api/routes/_normalize.py | Updates module docs to connected mode terminology. |
| src/gateway/api/main.py | Registers connected_mode router when in connected mode; updates comments accordingly. |
| src/gateway/api/deps.py | Returns no DB session when in connected mode (is_connected_mode). |
| scripts/web-search-tavily-adapter/README.md | Updates connected-mode wording for workspace defaults. |
| README.md | Updates user-facing docs to “connected mode” and points to connected-mode protocol doc. |
| docs/use-with-claude-code.md | Updates connected-mode wording in Claude Code integration docs. |
| docs/quickstart.md | Updates quickstart links and wording to connected mode. |
| docs/public/openapi.json | Regenerated OpenAPI descriptions reflecting connected-mode terminology. |
| docs/modes.md | Updates protocol doc link to connected-mode protocol. |
| docs/index.md | Updates docs index navigation text and protocol link to connected-mode protocol. |
| docs/files.md | Updates connected-mode wording in standalone-only note. |
| docs/deployment.md | Updates deployment guide wording from platform mode to connected mode. |
| docs/connected-mode-protocol.md | Renames and updates protocol doc title and connected-mode terminology. |
| CHANGELOG.md | Updates changelog wording to connected mode. |
| AGENTS.md | Updates engineering guidance to connected-mode naming and semantics. |
| .github/instructions/security-review.instructions.md | Updates security review guidance to connected mode naming and gating. |
Comments suppressed due to low confidence (1)
tests/unit/test_pipeline_settlement.py:97
- This docstring still calls the multi-attempt path the "platform-fallback" path, but the test parameter and mode terminology are now "connected". Updating the wording keeps the rename consistent and avoids ambiguity about whether this refers to the runtime mode or the upstream service.
"Platform mode" was a holdover from the any-llm platform era. The user-facing docs had already standardized on "connected to otari.ai" / "connected mode"; this aligns config, code, tests, and the remaining docs with that term. "platform" is kept only where it names the peer service (the otari.ai backend): the platform token, the `platform:` config block, `_platform.py`, and the resolve/usage helpers. Behavior: - `effective_mode` now returns "connected" instead of "platform"; the health endpoints report `"mode": "connected"`. - `OTARI_MODE` / config `mode` canonical value is now "connected"; "platform" is still accepted as a deprecated alias so existing configs keep working (covered by a new test). - `GatewayConfig.is_platform_mode` -> `is_connected_mode`. - Router module `routes/platform_mode.py` -> `routes/connected_mode.py` (tag "connected-mode"); disabled-endpoint detail now says "connected mode". - Doc `docs/platform-protocol.md` -> `docs/connected-mode-protocol.md`, title "Connected-mode protocol"; inbound links updated. - Integration test files `test_platform_mode_*` -> `test_connected_mode_*`. - OpenAPI spec regenerated from the updated route docstrings. Fixes #140 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Follow-up sweep found mode-term references the first pass missed because they were line-wrapped or used bare "platform" as mode shorthand: - two line-wrapped "platform\nmode" docstrings (_pipeline.py, the responses connected-mode test) - "platform-only" -> "connected-only" for the mcp_server_ids restriction (code comment + connected-mode-protocol doc) - "(or platform + tool-loop)" / "Tool-loop platform path" comments in the messages/responses pipelines - README: canonical OTARI_MODE value is now `connected` (legacy `platform` noted as still accepted) Service-level "platform" names (the peer service, PLATFORM_* env vars, platform-resolved attempts/route, platform-fallback mechanism) are deliberately kept. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Address Copilot review: when OTARI_MODE=platform (the legacy value) is set without a token, the error said "OTARI_MODE=connected requires ...", which is confusing for a user who typed "platform". Name the legacy value explicitly in the message. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Rebasing this branch onto main surfaced three references the original rename could not have touched, because the code carrying them landed on main after the branch diverged: - `_pipeline.py`: the sandbox-token branch still read `ctx.platform_mode`. That attribute is now `ctx.connected_mode`, so a connected-mode `otari_code_execution` request would have raised AttributeError. Renamed the attribute reference and the two surrounding "platform mode" comments. - `sandbox_backend.py`: a doc comment still said "Set in platform mode". - `test_connected_mode_chat.py`: the web-search token-forwarding test was still named `test_platform_mode_*`; renamed to match every other test in the file. References to the platform *service* (platform token, base URL, `web_search_url_targets_platform`) are intentionally left as "platform". Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
dd09af2 to
0aa5a61
Compare
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
docs/deployment.md (1)
64-68:⚠️ Potential issue | 🟡 Minor | ⚡ Quick winUpdate stale health endpoint example output.
The JSON example shows
"mode": "platform", but the actual/healthendpoint returns"mode": "connected"when connected mode is active. Update the example to match the current implementation.🔧 Proposed fix
The response includes platform reachability status: ```json -{"status": "healthy", "mode": "platform", "platform_reachable": "yes"} +{"status": "healthy", "mode": "connected", "platform_reachable": "yes"}</details> <details> <summary>🤖 Prompt for AI Agents</summary>Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.In
@docs/deployment.mdaround lines 64 - 68, The health endpoint JSON example in
the deployment.md file shows an outdated mode value that does not match the
current implementation. Update the example JSON response to replace the"mode": "platform"field with"mode": "connected"to accurately reflect what the
/healthendpoint actually returns when connected mode is active.</details> <!-- cr-comment:v1:8ae0dbf666fdf5adef279466 --> </blockquote></details> </blockquote></details>🧹 Nitpick comments (1)
tests/integration/test_connected_mode_responses.py (1)
28-33: ⚡ Quick winUse canonical connected-mode fixture naming and token env var
This fixture still uses legacy
platform_*naming andOTARI_PLATFORM_TOKEN. Renaming toconnected_clientand settingOTARI_AI_TOKENwould keep this module aligned with the rename intent and reduce legacy coupling in core connected-mode tests (legacy alias coverage can stay in dedicated config-compat tests).Suggested diff
-@pytest.fixture -def platform_client(monkeypatch: pytest.MonkeyPatch) -> Generator[TestClient]: - monkeypatch.setenv("OTARI_PLATFORM_TOKEN", "gw_test_token") +@pytest.fixture +def connected_client(monkeypatch: pytest.MonkeyPatch) -> Generator[TestClient]: + monkeypatch.setenv("OTARI_AI_TOKEN", "gw_test_token")Based on learnings, connected mode is derived from
OTARI_AI_TOKENpresence andplatformremains a legacy alias; using the canonical token in primary connected-mode tests keeps intent crisp.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@tests/integration/test_connected_mode_responses.py` around lines 28 - 33, The fixture `platform_client` uses legacy naming and the deprecated `OTARI_PLATFORM_TOKEN` environment variable instead of the canonical connected-mode naming and token. Rename the fixture function from `platform_client` to `connected_client` and change the monkeypatch call to set `OTARI_AI_TOKEN` instead of `OTARI_PLATFORM_TOKEN` to align with the canonical connected-mode configuration where connected mode is derived from the presence of `OTARI_AI_TOKEN` and `platform` is treated as a legacy alias.Source: Learnings
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. Outside diff comments: In `@docs/deployment.md`: - Around line 64-68: The health endpoint JSON example in the deployment.md file shows an outdated mode value that does not match the current implementation. Update the example JSON response to replace the `"mode": "platform"` field with `"mode": "connected"` to accurately reflect what the `/health` endpoint actually returns when connected mode is active. --- Nitpick comments: In `@tests/integration/test_connected_mode_responses.py`: - Around line 28-33: The fixture `platform_client` uses legacy naming and the deprecated `OTARI_PLATFORM_TOKEN` environment variable instead of the canonical connected-mode naming and token. Rename the fixture function from `platform_client` to `connected_client` and change the monkeypatch call to set `OTARI_AI_TOKEN` instead of `OTARI_PLATFORM_TOKEN` to align with the canonical connected-mode configuration where connected mode is derived from the presence of `OTARI_AI_TOKEN` and `platform` is treated as a legacy alias.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID:
949965d6-c23a-4ee9-b7cb-a6555da64813⛔ Files ignored due to path filters (1)
docs/public/openapi.jsonis excluded by!docs/public/openapi.json📒 Files selected for processing (37)
.github/instructions/security-review.instructions.mdAGENTS.mdREADME.mddocs/connected-mode-protocol.mddocs/deployment.mddocs/files.mddocs/index.mddocs/modes.mddocs/quickstart.mddocs/use-with-claude-code.mdscripts/web-search-tavily-adapter/README.mdsrc/gateway/api/deps.pysrc/gateway/api/main.pysrc/gateway/api/routes/_normalize.pysrc/gateway/api/routes/_pipeline.pysrc/gateway/api/routes/_platform.pysrc/gateway/api/routes/chat.pysrc/gateway/api/routes/connected_mode.pysrc/gateway/api/routes/health.pysrc/gateway/api/routes/messages.pysrc/gateway/api/routes/responses.pysrc/gateway/cli.pysrc/gateway/core/config.pysrc/gateway/main.pysrc/gateway/services/mcp_loop.pysrc/gateway/services/mcp_loop_messages.pysrc/gateway/services/mcp_loop_responses.pysrc/gateway/services/sandbox_backend.pytests/integration/test_batches_endpoint.pytests/integration/test_config_env_loading.pytests/integration/test_connected_mode_chat.pytests/integration/test_connected_mode_messages.pytests/integration/test_connected_mode_responses.pytests/integration/test_connected_mode_surface.pytests/unit/test_mcp_loop.pytests/unit/test_pipeline_settlement.pytests/unit/test_run_platform_attempts.py
Brings in the fallback/streaming fixes from main (retryable 404/405/409/410, exactly-once per-attempt usage reporting, bounded inline flush). Conflicts were limited to the connected-mode message tests, where main added a new 404 fall-through test and renamed/expanded the all-attempts-fail test while this branch had renamed the file and its test prefixes. Resolution keeps main's new tests and applies the platform_mode -> connected_mode prefix rename to them; same rename applied to a new streaming all-fail test main added to the chat suite. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
@njbrake I have been procrastinating a bit on this one for the only reason that I am not entirely sure if "connected" is the right term. What do you think if we had something like: |
|
I went with "connected" because it seems like we had already started adopting that term in the code base, but if you would prefer a different term, I have no strong opinion 😊 |
|
I think it would make more sense 😅 |
Per review feedback on #163, "connected" was ambiguous as a mode name (Otari connects to many things: web search, MCP, providers). Rename the runtime-mode term to "hybrid" across config, code, tests, and docs. - effective_mode now returns "hybrid"; health endpoints report "mode": "hybrid". The platform / platform_reachable reachability keys and db_status keep reporting "connected" (they describe the service connection, not the mode). - Config mode canonical value is "hybrid"; "platform" stays a deprecated alias. - GatewayConfig.is_connected_mode -> is_hybrid_mode (property + all call sites). - RequestContext.connected_mode -> hybrid_mode. - routes/connected_mode.py -> routes/hybrid_mode.py (tag "hybrid-mode"). - docs/connected-mode-protocol.md -> docs/hybrid-mode-protocol.md. - test_connected_mode_*.py -> test_hybrid_mode_*.py. - Descriptive "connected to otari.ai" prose is kept where it accurately describes what hybrid mode does (it is specific, not the ambiguous term). - OpenAPI spec regenerated from the updated route docstrings. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/gateway/api/routes/health.py`:
- Around line 85-87: In the health.py file, replace the raw status code integer
503 with the FastAPI status constant HTTP_503_SERVICE_UNAVAILABLE in the
HTTPException raised in this handler branch. First ensure that status is
imported from fastapi at the top of the file (if not already present), then
change the status_code parameter from 503 to status.HTTP_503_SERVICE_UNAVAILABLE
to maintain consistency with the codebase guidelines for using HTTP status
constants instead of raw integers.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 795bfb94-bbae-49cc-8d65-b5684f8c4655
⛔ Files ignored due to path filters (1)
docs/public/openapi.jsonis excluded by!docs/public/openapi.json
📒 Files selected for processing (37)
.github/instructions/security-review.instructions.mdAGENTS.mdREADME.mddocs/deployment.mddocs/files.mddocs/hybrid-mode-protocol.mddocs/index.mddocs/modes.mddocs/quickstart.mddocs/use-with-claude-code.mdscripts/web-search-tavily-adapter/README.mdsrc/gateway/api/deps.pysrc/gateway/api/main.pysrc/gateway/api/routes/_normalize.pysrc/gateway/api/routes/_pipeline.pysrc/gateway/api/routes/_platform.pysrc/gateway/api/routes/chat.pysrc/gateway/api/routes/health.pysrc/gateway/api/routes/hybrid_mode.pysrc/gateway/api/routes/messages.pysrc/gateway/api/routes/responses.pysrc/gateway/cli.pysrc/gateway/core/config.pysrc/gateway/main.pysrc/gateway/services/mcp_loop.pysrc/gateway/services/mcp_loop_messages.pysrc/gateway/services/mcp_loop_responses.pysrc/gateway/services/sandbox_backend.pytests/integration/test_batches_endpoint.pytests/integration/test_config_env_loading.pytests/integration/test_hybrid_mode_chat.pytests/integration/test_hybrid_mode_messages.pytests/integration/test_hybrid_mode_responses.pytests/integration/test_hybrid_mode_surface.pytests/unit/test_mcp_loop.pytests/unit/test_pipeline_settlement.pytests/unit/test_run_platform_attempts.py
✅ Files skipped from review due to trivial changes (18)
- docs/modes.md
- docs/files.md
- .github/instructions/security-review.instructions.md
- src/gateway/services/sandbox_backend.py
- docs/quickstart.md
- tests/unit/test_run_platform_attempts.py
- src/gateway/services/mcp_loop_messages.py
- docs/deployment.md
- src/gateway/api/routes/_normalize.py
- docs/use-with-claude-code.md
- src/gateway/api/routes/_platform.py
- AGENTS.md
- docs/hybrid-mode-protocol.md
- src/gateway/services/mcp_loop.py
- scripts/web-search-tavily-adapter/README.md
- docs/index.md
- tests/unit/test_mcp_loop.py
- src/gateway/services/mcp_loop_responses.py
🚧 Files skipped from review as they are similar to previous changes (1)
- tests/unit/test_pipeline_settlement.py
| raise HTTPException( | ||
| status_code=503, | ||
| detail={ |
There was a problem hiding this comment.
Use FastAPI status constants in this changed handler branch.
Line 86 uses a raw 503 literal. Please switch to status.HTTP_503_SERVICE_UNAVAILABLE to match the route guideline.
Suggested patch
- raise HTTPException(
- status_code=503,
+ raise HTTPException(
+ status_code=status.HTTP_503_SERVICE_UNAVAILABLE,
detail={
"status": "unhealthy",
"mode": "hybrid",🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/gateway/api/routes/health.py` around lines 85 - 87, In the health.py
file, replace the raw status code integer 503 with the FastAPI status constant
HTTP_503_SERVICE_UNAVAILABLE in the HTTPException raised in this handler branch.
First ensure that status is imported from fastapi at the top of the file (if not
already present), then change the status_code parameter from 503 to
status.HTTP_503_SERVICE_UNAVAILABLE to maintain consistency with the codebase
guidelines for using HTTP status constants instead of raw integers.
Source: Coding guidelines
The /health endpoint reports "mode": "hybrid" in hybrid mode, not "platform". Update the example output to match. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Description
Renames the legacy "platform mode" runtime-mode term to "hybrid mode" across config, code, tests, and docs (#140). "Platform mode" was a holdover from the any-llm platform era.
This PR initially renamed the mode to "connected mode", but on review (thanks @tbille) "connected" read as ambiguous: Otari connects to many things (web search, MCP, providers), so "connected mode" did not clearly name the otari.ai-backed runtime mode. The term is now "hybrid mode".
"platform" is kept only where it names the peer service (the otari.ai backend): the platform token, the
platform:config block,_platform.py, and the resolve/usage helpers.Behavior:
effective_modenow returns"hybrid"instead of"platform"; the health endpoints report"mode": "hybrid". The separateplatform/platform_reachablereachability keys (and the readinessdb_status) are unchanged: they report a service/DB connection, not the mode.mode/OTARI_MODEcanonical value is nowhybrid;platformis still accepted as a deprecated alias so existing configs keep working (test covers this).GatewayConfig.is_platform_modetois_hybrid_mode(property + all call sites).RequestContext.platform_modetohybrid_mode.routes/platform_mode.pytoroutes/hybrid_mode.py(taghybrid-mode); disabled-endpoint detail now says "hybrid mode".docs/platform-protocol.mdtodocs/hybrid-mode-protocol.md, title "Hybrid-mode protocol"; inbound links updated.test_platform_mode_*totest_hybrid_mode_*.The branch name (
refactor/rename-connected-mode) is left as-is to avoid churning the PR; it is cosmetic.PR Type
Relevant issues
Fixes #140
Checklist
tests/unit,tests/integration).make lint,make typecheck,make test).uv run python scripts/generate_openapi.py).AI Usage
AI Model/Tool used:
Claude Code (Claude Opus 4.8)
Any additional AI details you'd like to share:
The rename was carried out by Claude Code via back-and-forth with @njbrake; the decisions (term choice, scope, what to keep) are his.
NOTE:
When responding to reviewer questions, please respond yourself rather than copy/pasting reviewer comments into an AI and pasting back its answer. We want to discuss with you, not your AI :)