Skip to content

Report Mongo errors from the semantic knowledge tools instead of raising - #83

Merged
linted merged 1 commit into
mainfrom
worktree-knowledge-query-error-handling
Nov 18, 2026
Merged

linted merged 1 commit into
mainfrom
worktree-knowledge-query-error-handling

Conversation

@linted

@linted linted commented Nov 18, 2026

Copy link
Copy Markdown
Owner

Problem

query_knowledge and query_knowledge_global were bare create_retriever_tool
wrappers with no error handling. A PyMongoError escaped the tools node and killed
the whole run, cancelling sibling tool calls — in trace 01a1ec54-a460-7282-a96c-740b8ef7627c
it took down a prototype-fixer task 16 minutes in.

The trigger was re_knowledge_index existing but not being queryable
("cannot query vector index ... while in state NOT_STARTED"); mongot had paused
initial syncs because the Mongo host's disk was 89% full. The startup index check
only verifies the index exists, so it can't rule this out.

Fix

  • _safe_retriever_tool() wraps create_retriever_tool (sync + async) and returns a
    warning pointing the agent at query_by_address / query_by_category / query_by_tags,
    matching how save_knowledge / update_knowledge already handle PyMongoError.
  • Offline tests with a fake retriever cover normal formatting and the NOT_STARTED failure.

Testing

lint, typecheck, and ./scripts/test.sh pass (302 passed). Integration tests not run.

query_knowledge and query_knowledge_global were bare create_retriever_tool
wrappers, so a PyMongoError escaped the tools node and killed the run,
cancelling any sibling tool calls (a prototype-fixer task, 16 minutes in).
The trigger was a vector index that existed but was not yet queryable
("state NOT_STARTED"), which the startup index check cannot rule out.

Wrap both in _safe_retriever_tool, which returns a warning pointing the
agent at the direct query tools, matching save_knowledge/update_knowledge.
@linted
linted merged commit 5a3c562 into main Nov 18, 2026
2 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.

1 participant