fix(agent): refresh delegate_{toolkit} tools on first turn for web channel#1666
Closed
graycyrus wants to merge 1 commit into
Closed
fix(agent): refresh delegate_{toolkit} tools on first turn for web channel#1666graycyrus wants to merge 1 commit into
graycyrus wants to merge 1 commit into
Conversation
…nnel registers them The synchronous agent builder passes `&[]` for connected_integrations to `collect_orchestrator_tools()` because it cannot call the async Composio fetcher. After PR tinyhumansai#1314 removed `spawn_subagent` and rewrote the prompt to advertise `delegate_{toolkit}` tools, the web/Tauri channel's tool schema diverged from the prompt — the model sees `delegate_gmail` in prose but cannot call it. Add `refresh_delegation_tools()` on `Agent`, called immediately after `fetch_connected_integrations()` on the first turn. It re-synthesises skill-delegation tools with the live integrations list and merges them into `tools`, `tool_specs`, `visible_tool_names`, and `visible_tool_specs` before `build_system_prompt()` runs. Also adds `base_definition_id` to `Agent` so the original definition ID survives the web channel's `set_agent_definition_name()` mangling (e.g. `"orchestrator"` → `"orchestrator_thread-6ad..."`). Closes tinyhumansai#1659
Contributor
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Comment |
Member
|
this is kidna fixed now in #1670 |
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
refresh_delegation_tools()onAgent, called afterfetch_connected_integrations()on the first turn — re-synthesises skill-delegation tools (delegate_gmail,delegate_notion, …) with the live integrations list and merges them into the tool schema before the system prompt is builtbase_definition_idfield toAgentto preserve the original definition ID through the web channel'sset_agent_definition_name()mangling ("orchestrator"→"orchestrator_thread-6ad...")&[]comment at thecollect_orchestrator_toolscall sites to document the refresh contractRoot cause
PR #1314 removed
spawn_subagentfrom the orchestrator's allowed tools and rewrote the integrations prompt to advertisedelegate_{toolkit}tools. The synchronous builder (builder.rs) passes&[]for connected integrations (can't call async Composio API), so zero skill-delegation tools are registered. Meanwhilefetch_connected_integrations()populates the prompt correctly — the model seesdelegate_gmailin prose but can't call it, falling through todelegate_tools_agentwhich refuses.Changes
types.rsbase_definition_idfield onAgent+AgentBuilderbuilder.rsbase_definition_id, update&[]commentsturn.rsrefresh_delegation_tools()method + call on first turnruntime.rsbase_definition_id()accessortests.rsTest plan
refresh_delegation_tools_populates_skill_tools— connected gmail + github →delegate_gmailanddelegate_githubappear in tool schemarefresh_delegation_tools_noop_when_no_integrations— empty integrations = no-oprefresh_delegation_tools_skips_already_registered— calling twice doesn't duplicate toolscargo check(core + Tauri shell) passescargo test— 6566 passed, 1 pre-existing failure (unrelated config test)cargo fmt --checkpassespnpm typecheck/pnpm lint/pnpm format:checkpassCloses #1659