HKUDS/DeepTutor · warning · HTTPException
Tool call not found
Error message
Tool call not found
What it means
404 from GET /co-writer/tool_calls/{operation_id} when no file matching '{operation_id}_*.json' exists in the tool_calls directory. The glob pattern means the id must be the prefix of a saved tool-call file.
Source
Thrown at deeptutor/api/routers/co_writer.py:509
for op in history:
if op.get("id") == operation_id:
return op
raise HTTPException(status_code=404, detail="Operation not found")
except HTTPException:
raise
except Exception as e:
raise HTTPException(status_code=500, detail=str(e))
@router.get("/tool_calls/{operation_id}")
async def get_tool_call(operation_id: str):
"""Get tool call details"""
try:
# Find matching file
for filepath in tool_calls_dir().glob(f"{operation_id}_*.json"):
with open(filepath, encoding="utf-8") as f:
return json.load(f)
raise HTTPException(status_code=404, detail="Tool call not found")
except HTTPException:
raise
except Exception as e:
raise HTTPException(status_code=500, detail=str(e))
# ─────────────────────────────────────────────────────────────────────────────
# Document CRUD (multi-project Co-Writer)
# ─────────────────────────────────────────────────────────────────────────────
# Storage builds paths as `documents/doc_{doc_id}`; an unvalidated id like
# "a/../../x" would escape the documents root (and DELETE runs rmtree).
_DOC_ID_RE = re.compile(r"^[0-9a-f]{8,32}$")
def _validate_doc_id(doc_id: str) -> str:
if not _DOC_ID_RE.fullmatch(doc_id):
raise HTTPException(status_code=404, detail="Document not found")View on GitHub (pinned to 3e82f13042)
Solutions
- List the tool_calls directory (or history endpoint) to confirm which ids exist
- Re-run the operation if artifacts were cleaned
- Return 404 gracefully in the client
Defensive patterns
Strategy: try-catch
Try / catch
resp = client.get(f'/co-writer/tool_calls/{op_id}')
if resp.status_code == 404:
skip() # no artifacts retained for this op Prevention
- Expect 404 for operations that had no tool calls
- Treat tool_calls as ephemeral artifacts; don't build flows that require them long-term
When it happens
Trigger: GET /co-writer/tool_calls/<id> where no tool_calls/<id>_*.json file exists — unknown id, cleaned tool_calls dir, or operation that produced no tool calls.
Common situations: Tool-call artifacts pruned by cleanup jobs, restart with fresh data dir, or a UI holding a stale operation id.
Understand the failure class
Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.
Related errors
- Operation not found
- Document not found
- Entry not found
- No default knowledge base is configured
- Knowledge base '{requested}' not found
AI-assisted analysis of HKUDS/DeepTutor@3e82f13042 (2026-08-27).
Data as JSON: /api/errors/19ab8c44a5f496a3.
Report an issue: GitHub.