Repository navigation
[Agent|Engine] Give the agent only to models that can call tools - #2150
Merged
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. Note Currently processing new changes in this PR. This may take a few minutes, please wait... ⚙️ Run configurationConfiguration used: Repository: MODSetter/SurfSense/.coderabbit.yaml Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (12)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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 |
This was referenced Oct 2, 2026
This branch had an error being deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
supports_tool_callsfor a local model's template, or the remote catalog recordstool_call: trueunder the connection's catalog provider. Unknown or unreadable counts as no, and the thread opens as a chat.agent_answersis renamedselected_model_can_run_agent, after what it decides.409before any prompt is sent. A thread left with no model still gets the existing "no chat model selected" answer.supports_tool_callsbesidesupports_tools: a template can render tools while llama-server parses none of its calls.test_engine_choice.pycovers each case against the real catalog and a stand-in llama-server; the agent-thread fixture now selectsgpt-4o-mini(catalog provideropenai), and a new test checks the send-time refusal.agent.md,chat.md,01-which-engine.mdand the proposal README. The old Known gap is gone; a new one records that the composer shows the refusal as an error rather than offering a new thread.Follows #2135
High-level PR Summary
This PR modifies the agent engine selection logic to ensure only models that can actually call tools are assigned to agent threads. It adds checks for both local models (via llama-server's
supports_tool_callscapability) and remote models (via catalog'stool_callfield), preventing the agent from being assigned to models that would fail to execute tool calls. The change includes runtime validation that refuses turns sent to agent threads when the selected model changes to one without tool-calling support.⏱️ Estimated Review Time: 15-30 minutes
💡 Review Order Suggestion
surfsense_local/backend/modules/llm/providers/llamacpp/capabilities.pysurfsense_local/backend/modules/agent/engine_choice.pysurfsense_local/backend/modules/agent/agent_threads/turn.pysurfsense_local/backend/modules/chat/router.pysurfsense_local/backend/tests/integration/agent/conftest.pysurfsense_local/backend/tests/integration/agent/test_agent_threads.pysurfsense_local/backend/tests/integration/agent/test_engine_choice.pysurfsense_local/backend/tests/unit/llm/test_system_role.pydocs/proposals/agent/01-which-engine.mddocs/architecture/agent.mddocs/architecture/chat.mddocs/proposals/agent/README.md