Skip to content

fix(ai): strip the provider key from ai.getDefaultModel for user sessions (review fixes for #1167) - #1172

Merged
HexaField merged 1 commit into
fix/user-token-node-operationsfrom
review-fix/1167-default-model-key
Sep 26, 2026
Merged

HexaField merged 1 commit into
fix/user-token-node-operationsfrom
review-fix/1167-default-model-key

Conversation

@data-bot-coasys

Copy link
Copy Markdown
Contributor

Stacked on #1167. Implements my review 5327106839 on it.

Changes:

  • ai.getDefaultModel returns the provider key to users (blocking, ai_ws.rs:54). The result now goes through models_for_session, like ai.models. Test: user_sessions_get_the_default_model_without_its_provider_key in model_key_tests calls the handler and checks that a user session gets an empty apiKey and an operator session gets the key. It fails on fix(api): keep user sessions off node operations; sign as the user #1167's head (the user got sk-provider-secret) and passes here.
  • Failed profile read drops the DM language (agent_ws.rs:254). It now returns the error, as the DM branch does.
  • MCP profile tools write direct_message_language: None (same comment). update_agent_perspective (mcp/tools/profiles.rs:104) now keeps the stored DM language. I left :82 as it is: that is the fallback for a user with no stored profile, so there is no DM language to keep. No new test for these two.

Not done:

  • guards.rs:15, a user token passing the guard when multi-user mode reads as off. The choice is between merging fix(auth): fail closed when a token stops working #1168 first and reading sub in the guard, so it's your call.
  • guards.rs:14, one helper shared with fix(events): keep app tokens, webhook secrets and other users' perspectives out of broadcasts #1164's refuse_app_management_by_users. That's a cross-PR change for whichever PR merges second.
  • guards.rs:14, guarding language.remove, language.writeSettings, runtime.addTrustedAgents/deleteTrustedAgents, runtime.addFriends/removeFriends, runtime.add/removeLinkLanguageTemplates and runtime.addHcAgentInfos. Which calls users may make is a product decision.
  • agent_ws.rs:522, language.publish/applyTemplate signing as the node for user sessions. The review marked it as a follow-up.

Tests: cargo test --release -p ad4m-executor --lib api:: (326 passed), plus ai_ws:: (3), node_operation_tests (4) and profile (1).

🤖 Generated with Claude Code

…ions

ai.getDefaultModel returned db.get_model(id) as stored, and users hold
AI_READ, so a user session still got the default model's provider key.
It now goes through models_for_session, like ai.models.

Also:
- agent.updateProfile returns the error when the user's profile cannot
  be read, instead of treating it as "no DM language" and dropping it.
- The MCP profile perspective update keeps the user's DM language
  instead of writing None.

Implements review 5327106839 on #1167.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Sep 26, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: 675a6f67-a924-4340-be71-de9591d40702

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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.

@HexaField
HexaField merged commit 9417b40 into fix/user-token-node-operations Sep 26, 2026
12 checks passed
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