fix(agent): make the tool-selection timeout configurable#5772
Open
MummIndia wants to merge 1 commit into
Open
Conversation
Tool selection has a 1.5s budget covering three steps: index init, MCP indexing, and retrieval. That suits a warm index on quick hardware. It is tight anywhere else, because the steps run inside a request while the app may also be loading FastEmbed, reaching ChromaDB and spawning MCP servers. The failure mode is what makes this worth fixing rather than the number itself. On expiry, selection falls back to ALWAYS_AVAILABLE — which contains no MCP tool at all. Every MCP server therefore disappears for that turn, and the agent reports it does not have tools it is connected to and could call directly. The warning line says the timeout expired; nothing says the consequence was dropping the entire MCP surface, so the two are not obviously related when reading logs. Makes the value overridable via ODYSSEUS_TOOL_SELECTION_TIMEOUT so a slower or busier deployment can buy headroom without patching. The default is unchanged at 1.5s, so nothing moves for existing installs. Also adds the missing `import os` — the module did not import it and made no use of `os.` anywhere, so the new call would have raised NameError at import time. Worth flagging because py_compile does not catch it: it checks syntax, not name resolution. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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
Tool selection has a 1.5s budget covering three steps: index init, MCP indexing, and
retrieval. That suits a warm index on quick hardware. It is tight anywhere else,
because the steps run inside a request while the app may also be loading FastEmbed,
reaching ChromaDB and spawning MCP servers.
The failure mode is what makes this worth fixing rather than the number itself. On
expiry, selection falls back to
ALWAYS_AVAILABLE— which contains no MCP tool at all.Every MCP server therefore disappears for that turn, and the agent reports it does not
have tools it is connected to and could call directly. The warning line says the
timeout expired; nothing says the consequence was dropping the entire MCP surface.
Makes the value overridable via
ODYSSEUS_TOOL_SELECTION_TIMEOUT. The default isunchanged at 1.5s, so nothing moves for existing installs.
Also adds the missing
import os— the module did not import it and made no use ofos.anywhere, so the new call would have raisedNameErrorat import time. Worthflagging because
py_compiledoes not catch it: it checks syntax, not name resolution.Target branch
dev, notmain.Linked Issue
Fixes #5771
Type of Change
Checklist
devdocker compose up) and verified the change works end-to-end.How to Test
With an MCP server connected, send an agent request while the app is still warming
up. Before — the
[tool-rag]warning fires and the following[agent-debug]line contains no
mcp__*tool; the agent reports it has no such tool.Set
ODYSSEUS_TOOL_SELECTION_TIMEOUT=15and repeat. Retrieval completes and themcp__*tools appear intool_names.Unset it and confirm the default is still 1.5s:
Confirm the module imports cleanly (
python -c "import src.agent_loop"), which iswhat catches the missing
import os.Visual / UI changes
None.
src/agent_loop.pyonly — a module-level constant and an import.