Commit graph

4 commits

Author SHA1 Message Date
Vadym Samoilenko
4c6696ed2b feat: add file download proxy and normalize code interpreter file objects
- Add /api/v1/code-interpreter/files/{session_id}/{file_id} proxy endpoint
  so the browser can download files from the internal LibreCodeInterpreter
- Normalize file objects in CodeInterpreterTool to consistent {id, name, session_id}
  shape regardless of which field names LibreCodeInterpreter returns

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-30 21:36:23 +01:00
Vadym Samoilenko
d3d16f42a5 fix: switch back to /exec for file detection, handle keepalive whitespace in response
/exec/programmatic is for agentic tool-calling and returns files:[].
/exec uses the runner with savefig/open keyword detection and uploads
files to MinIO. Response is streaming with whitespace keepalive then
JSON body — parse with resp.text.strip().

Also include download URLs in tool display output.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-30 21:19:56 +01:00
Vadym Samoilenko
e0b1db36a8 fix: use /exec/programmatic endpoint — /exec is streaming (chunked), programmatic returns JSON
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-30 21:16:23 +01:00
Vadym Samoilenko
f2b5dce63a feat: code interpreter, agent analytics/execute APIs, usage sync, RAG scoping fixes
**Phase 1 — Agent Usage Sync to AgentHub Collector**
- Add agent_usage service: per-agent stats (messages, tokens, conversations, unique users, first/last used)
- Collector sync now includes usage data in payload; sync_agent accepts optional db session
- Celery beat task runs every 6h to sync all active agents with fresh usage stats

**Phase 2 — LibreCodeInterpreter Integration**
- Add code-interpreter, redis, minio services to docker-compose.prod.yml
- CodeInterpreterTool (BaseTool): sandboxed execution via /exec, 13 languages, Python session persistence via conversation_id
- ToolContext extended with conversation_id and agent_slug
- enable_code_interpreter boolean on Agent model (migration 027), tool seeded in tool_definitions (migration 026)
- Code interpreter auto-injected into agent tools when enabled
- Frontend: CodeExecutionResult component with terminal-style stdout/stderr/files rendering

**Phase 3 — Agent API Endpoints**
- GET /api/v1/agents/{slug}/analytics — per-agent usage stats + daily time series
- POST /api/v1/agents/{slug}/execute — synchronous programmatic agent execution (non-SSE)
- Sub-routes registered before /{slug} to avoid FastAPI route conflict

**Phase 4 — Fix Department & Region RAG Scoping**
- Department filter now OR-includes global (null department) docs, matching region filter behaviour
- retriever.search_documents/retrieve_and_prepare/query accept department_ids/region_codes lists
- MatchAny used for multi-value Qdrant filters; chat.py passes full arrays from knowledge_scope
- Admin PATCH /users/{id} now validates region_code against the regions table

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-30 20:13:27 +01:00