V3 enhancement#98
Conversation
…tection, and silent reset notifications
… rolodex - Rewrite buildQverisSection() as a structured 6-step decision tree with explicit anti-patterns (local ops, docs/tutorials, non-English queries) - Update qveris_search description and query param with negative boundaries and GOOD/BAD examples to prevent task-goal searches - Add qveris_get_by_ids tool: calls POST /tools/get-by-ids to verify known tools without a full search; registered in tool catalog, policy, and prompt - Add session-scoped tool rolodex: records successful executes, annotates search results with previously_used/session_uses, exposes session_known_tools - Update coreToolSummaries for all three QVeris tools with boundary-aware text - Replace over-broad AGENTS.md 'Prioritize qveris' rule with routing-aware guidance - Add tests: get-by-ids execution, rolodex recording, search annotation, descriptions
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances the agent's capabilities by introducing natural language model switching and optimizing QVeris tool interactions to improve efficiency and reduce API costs. It also strengthens long-term memory management with new proactive hooks and improves channel integrations, particularly for Discord and Telegram, by enabling persistent ACP bindings and asynchronous message processing. These changes aim to provide a more intuitive, reliable, and performant agent experience across various platforms. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Ignored Files
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This is an impressive enhancement, introducing significant new capabilities for model switching and QVeris tool usage. The implementation of the switch_model tool with fuzzy matching and ambiguity detection is well-executed, and the QVeris routing decision tree is a major improvement for agent guidance. The code is well-structured, thoroughly tested, and accompanied by excellent documentation updates. I have one suggestion for a minor refactoring to improve code reuse and maintainability.
Note: Security Review did not run due to the size of the PR.
| const internalKey = resolveInternalSessionKey({ key: sessionKey, alias, mainKey }); | ||
| const entryByInternal = store[internalKey]; | ||
| const entryByRaw = store[sessionKey]; | ||
| const entry = entryByInternal ?? entryByRaw; | ||
| const resolvedKey = entryByInternal ? internalKey : sessionKey; | ||
| if (!entry) { | ||
| throw new Error(`Unknown session: ${sessionKey}`); | ||
| } |
There was a problem hiding this comment.
The logic here to resolve a session entry from the session store is very similar to the resolveSessionEntry helper function in src/agents/tools/session-status-tool.ts. To reduce code duplication and ensure consistent session resolution behavior, consider extracting resolveSessionEntry into a shared location (like src/agents/tools/sessions-helpers.ts) and using it here. The version in session-status-tool.ts is also more robust as it checks more candidate keys.
Summary
/modelslash commands — and when a model override silently became invalid it reset with no notification; (2) QVeris tools lacked routing discipline, causing agents to callqveris_searchfor local operations, documentation lookups, and config queries, burning API credits and receiving irrelevant results.switch_modeltool — new agent tool with fuzzy model matching (aliases, partial names, fullprovider/modelrefs), ambiguity detection (surfaces candidates list when top scores are within 30 points),model="default"reset, and asystem_eventemitted on every switch. Silent resets (override removed from allowlist) now also emit asystem_event.session_statusremains read-only.buildQverisSection()rewritten as a 6-step decision tree with explicit anti-patterns.qveris_searchdescription andqueryparam updated with negative-boundary text and GOOD/BAD examples.qveris_get_by_idstool — new tool callingPOST /tools/get-by-ids; skips full search for known tool IDs; registered in catalog, policy groups, andcoreToolSummaries.qveris_executecalls; annotates search results withpreviously_used/session_uses; surfacessession_known_toolsin search payloads.switch_modelnatural-language usage, silent reset notifications, memory hooks, and README improvements./modelslash command behavior, existingqveris_search/qveris_executeresponse shapes,session_statusread-only semantics.Change Type (select all)
Scope (select all touched areas)
Linked Issue/PR
User-visible / Behavior Changes
switch_modeltool handles resolution, ambiguity prompting, and confirmation.qveris_get_by_idstool is available when QVeris is enabled. Existing sessions unaffected — additive only.qveris_searchresults may now includesession_known_tools,previously_used, andsession_usesfields after successful executions in the same session.Security Impact (required)
Yes—switch_modelcan write to the session store (sessions.json) and enqueue system events. Scoped to the current session only; no cross-session or remote execution surface.NoYes—qveris_get_by_idsaddsPOST https://qveris.ai/api/v1/tools/get-by-ids, using the existingQVERIS_API_KEYBearer token, subject to the same timeout config.Yes— two new tools added:switch_model(incoding/messagingprofiles, denied in subagents viaSUBAGENT_TOOL_DENY_ALWAYS),qveris_get_by_ids(ingroup:qveris,group:web,group:openclaw).No— rolodex is in-memory, session-scoped, never persisted or transmitted.switch_modelwrites tosessions.jsonviaupdateSessionStore— same code path already used by existing session management.qveris_get_by_idsuses the same already-trusted API key and base URL asqveris_search. No new secrets or elevated permissions introduced.Repro + Verification
Environment
tools.qveris.enabled: true,tools.qveris.apiKey: qv_..., allowlist with multiple models configuredSteps
switch_modeland confirm the switch.switch_model(model="default").agents.allowedModels, send a message — session silently resets; agent should notify of the change.session_statusorread, NOTqveris_search.qveris_get_by_idswith the knowntool_idinstead of repeatingqveris_search.Expected
switch_modelcalled with correct resolution; system event emitted; takes effect next message.qveris_searchcall.qveris_get_by_idsused;session_known_toolsvisible in second search payload.Actual
Evidence
src/agents/openclaw-tools.switch-model.test.ts(240 lines, new),src/agents/tools/qveris-tools.test.ts(7 new tests),src/agents/system-prompt.test.ts(2 updated + 1 new). Build clean,pnpm build0 errors.Human Verification (required)
switch_modelfuzzy resolution (aliases, partial names, exact provider/model); ambiguity detection at 30-point score gap boundary;model="default"/"reset"path; silent override reset system event;qveris_get_by_idshappy path and empty-IDs error; rolodex recording on successful execute;session_known_tools+previously_usedannotation in search results; negative-boundary text inqveris_searchdescription.qveris_get_by_idsstep omitted from system prompt when tool not in available set; subagent deny list correctly excludesswitch_model.get-by-idsendpoint in production (mocked in tests); LLM behavioral improvement in real conversations;switch_modelbehavior whensessions.jsonwrite fails mid-operation.Compatibility / Migration
Yes— no removed tools, no config schema changes, no changed response shapes (only additive fields and new tools).NoNoFailure Recovery (if this breaks)
git revert 72f406671 b9da41f4d(two separate reverts, in this order). Alternatively,tools.qveris.enabled: falsedisables all QVeris tools;switch_modelcan be removed viatools.deny: ["switch_model"]in config.src/agents/tools/switch-model-tool.ts,src/agents/tools/qveris-tools.ts,src/agents/system-prompt.ts,src/auto-reply/reply/model-selection.ts.switch_modelreturningambiguous: trueloop if ambiguity threshold is too low for a specific allowlist — increaseAMBIGUITY_GAPconstant or add explicit aliases.qveris_get_by_idsreturning 404 if the endpoint is not live on the target QVeris environment — will surface aserror_type: "http_error", agent falls back toqveris_searchnaturally.Risks and Mitigations
switch_modelambiguity detection may surface too many candidates for dense allowlists (many models with similar names), making the UX noisy.AMBIGUITY_GAPwas calibrated against the test suite. Users can reduce noise by configuring explicit model aliases.POST /tools/get-by-idsmay not be available on all QVeris environments (staging, self-hosted).QverisErrorResultwitherror_type: "http_error"on failure; no crash, agent falls back toqveris_searchgracefully.!isMinimaland only rendered whenqveris_searchis in the tool set. Subagent prompts are unaffected.