Skip to content

refactor(chat-agent): introduce sub-agents for high-context tools#76

Merged
larryro merged 14 commits into
mainfrom
claude/refactor-chat-agent-subagents-TYYGe
Jan 5, 2026
Merged

refactor(chat-agent): introduce sub-agents for high-context tools#76
larryro merged 14 commits into
mainfrom
claude/refactor-chat-agent-subagents-TYYGe

Conversation

@larryro
Copy link
Copy Markdown
Collaborator

@larryro larryro commented Jan 4, 2026

Summary

Refactor the chat agent to delegate high-context tools to specialized sub-agents, following the existing workflow_assistant pattern. This prevents large tool outputs (web pages, documents, database results) from polluting the main agent's context window.

Changes

New Sub-Agents

Sub-Agent Tools Max Steps Role Restriction
web_assistant web_read 5 None
document_assistant pdf, image, docx, pptx, generate_excel 15 None
integration_assistant integration, integration_introspect, verify_approval 20 admin/developer

Chat Agent Tool Changes

Before (13 tools):

  • Direct: rag_search, web_read, pdf, image, generate_excel, docx, pptx, customer_read, product_read, integration, integration_introspect, verify_approval, workflow_assistant

After (8 tools):

  • Direct (fast, bounded output): customer_read, product_read, rag_search, context_search
  • Sub-agents (context isolation): web_assistant, document_assistant, integration_assistant, workflow_assistant

Benefits

  • Context isolation - Sub-agent context is discarded after use, only summarized result returns to main agent
  • ~40-50% token savings on tool schema overhead
  • Better specialization - Each sub-agent has domain-specific instructions
  • Simpler maintenance - Isolated tool groups are easier to modify and test

Files

Created (9)

  • convex/lib/create_{web,document,integration}_agent.ts - Agent factories
  • convex/agent_tools/sub_agents/{web,document,integration}_assistant_tool.ts - Delegation tools
  • convex/agent_tools/sub_agents/instructions/{web,document,integration}_instructions.ts - Agent instructions

Modified (2)

  • convex/agent_tools/tool_registry.ts - Added 3 new tool registrations
  • convex/lib/create_chat_agent.ts - Updated default tool set

Test Plan

  • Verify web_assistant correctly delegates to web_read (search + fetch_url workflow)
  • Verify document_assistant handles all file operations (pdf, image, docx, pptx, generate_excel)
  • Verify integration_assistant handles integrations with approval flow
  • Verify parentThreadId is correctly passed for approval card linking
  • Verify role restriction works for integration_assistant (admin/developer only)
  • Verify direct tools (customer_read, product_read, rag_search, context_search) still work fast
  • Verify no regression in existing workflow_assistant functionality

Summary by CodeRabbit

  • New Features
    • Added Document, Integration, Web, and Integration Batch assistant tools for delegated handling of documents, integrations, web content, and parallel integration ops.
    • Introduced a combined "search_and_fetch" web workflow to return search results plus fetched page content.
    • Sub-agent delegation and sub-threading to isolate large/long-running tasks.
    • Chat metadata now captures response duration and per-sub-agent token usage for improved diagnostics.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jan 4, 2026

📝 Walkthrough

Walkthrough

Adds multiple sub-agent systems and supporting infrastructure: web_assistant, document_assistant, integration_assistant, integration_batch, and workflow changes. New agent factories (createWebAgent, createDocumentAgent, createIntegrationAgent), instruction templates, and sub-agent tools are introduced and registered. Implements sub-thread management (getOrCreateSubThread), token/usage telemetry (durationMs, subAgentUsage) across chat and message metadata, search-and-fetch web helper, integration batch execution, SQL operation summaries, and schema updates for messageMetadata and related persistence. RAG, Cognee, and background GC/cleanup behaviors are also adjusted.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related issues

Possibly related PRs

  • tale-project/poc2#481: Overlaps on integration subsystem changes (integration agent/tools, batch execution, integration-related types), directly related to this PR’s integration agent and batch tooling.
  • tale-project/poc2#354: Modifies the tool registry and introduces workflow/agent tooling similar to this PR’s additions to TOOL_REGISTRY and new sub-agent tools.
  • tale-project/poc2#476: Alters rag/app main lifecycle and GC/cleanup behavior; closely related to this PR’s changes to periodic GC cleanup and RAG configuration handling.

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 6

📜 Review details

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro (Legacy)

📥 Commits

Reviewing files that changed from the base of the PR and between 9de8ab9 and 22ea622.

📒 Files selected for processing (11)
  • services/platform/convex/agent_tools/sub_agents/document_assistant_tool.ts
  • services/platform/convex/agent_tools/sub_agents/instructions/document_instructions.ts
  • services/platform/convex/agent_tools/sub_agents/instructions/integration_instructions.ts
  • services/platform/convex/agent_tools/sub_agents/instructions/web_instructions.ts
  • services/platform/convex/agent_tools/sub_agents/integration_assistant_tool.ts
  • services/platform/convex/agent_tools/sub_agents/web_assistant_tool.ts
  • services/platform/convex/agent_tools/tool_registry.ts
  • services/platform/convex/lib/create_chat_agent.ts
  • services/platform/convex/lib/create_document_agent.ts
  • services/platform/convex/lib/create_integration_agent.ts
  • services/platform/convex/lib/create_web_agent.ts
🧰 Additional context used
📓 Path-based instructions (3)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.{ts,tsx}: USE implicit typing whenever possible in TypeScript
DO NOT use type casting. Avoid any, and unknown whenever possible in TypeScript

Files:

  • services/platform/convex/agent_tools/sub_agents/instructions/document_instructions.ts
  • services/platform/convex/agent_tools/sub_agents/instructions/integration_instructions.ts
  • services/platform/convex/lib/create_integration_agent.ts
  • services/platform/convex/agent_tools/sub_agents/document_assistant_tool.ts
  • services/platform/convex/lib/create_document_agent.ts
  • services/platform/convex/agent_tools/sub_agents/instructions/web_instructions.ts
  • services/platform/convex/agent_tools/sub_agents/web_assistant_tool.ts
  • services/platform/convex/lib/create_chat_agent.ts
  • services/platform/convex/agent_tools/sub_agents/integration_assistant_tool.ts
  • services/platform/convex/lib/create_web_agent.ts
  • services/platform/convex/agent_tools/tool_registry.ts
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.{ts,tsx,js,jsx}: ALWAYS put imports at the top and exports at the bottom. Keep them sorted correctly
PREFER named exports. AVOID default exports (only if needed)

Files:

  • services/platform/convex/agent_tools/sub_agents/instructions/document_instructions.ts
  • services/platform/convex/agent_tools/sub_agents/instructions/integration_instructions.ts
  • services/platform/convex/lib/create_integration_agent.ts
  • services/platform/convex/agent_tools/sub_agents/document_assistant_tool.ts
  • services/platform/convex/lib/create_document_agent.ts
  • services/platform/convex/agent_tools/sub_agents/instructions/web_instructions.ts
  • services/platform/convex/agent_tools/sub_agents/web_assistant_tool.ts
  • services/platform/convex/lib/create_chat_agent.ts
  • services/platform/convex/agent_tools/sub_agents/integration_assistant_tool.ts
  • services/platform/convex/lib/create_web_agent.ts
  • services/platform/convex/agent_tools/tool_registry.ts
**/convex/**/*.{ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

**/convex/**/*.{ts,tsx}: CONSIDER TO use rate limiting and action caching in Convex
DO NOT use .collect(), use for await (const ... of ...) instead in Convex

Files:

  • services/platform/convex/agent_tools/sub_agents/instructions/document_instructions.ts
  • services/platform/convex/agent_tools/sub_agents/instructions/integration_instructions.ts
  • services/platform/convex/lib/create_integration_agent.ts
  • services/platform/convex/agent_tools/sub_agents/document_assistant_tool.ts
  • services/platform/convex/lib/create_document_agent.ts
  • services/platform/convex/agent_tools/sub_agents/instructions/web_instructions.ts
  • services/platform/convex/agent_tools/sub_agents/web_assistant_tool.ts
  • services/platform/convex/lib/create_chat_agent.ts
  • services/platform/convex/agent_tools/sub_agents/integration_assistant_tool.ts
  • services/platform/convex/lib/create_web_agent.ts
  • services/platform/convex/agent_tools/tool_registry.ts
🧠 Learnings (12)
📚 Learning: 2025-07-20T08:40:24.693Z
Learnt from: CR
Repo: talecorp/poc PR: 0
File: .cursor/rules/ai.mdc:0-0
Timestamp: 2025-07-20T08:40:24.693Z
Learning: Applies to **/actions/*.ts : For text generation, use the `generateObject` or similar functions from the AI SDK

Applied to files:

  • services/platform/convex/agent_tools/sub_agents/instructions/document_instructions.ts
  • services/platform/convex/lib/create_chat_agent.ts
📚 Learning: 2025-07-20T08:40:24.693Z
Learnt from: CR
Repo: talecorp/poc PR: 0
File: .cursor/rules/ai.mdc:0-0
Timestamp: 2025-07-20T08:40:24.693Z
Learning: Applies to **/lib/**/*.ts : For text generation, use the `generateObject` or similar functions from the AI SDK

Applied to files:

  • services/platform/convex/agent_tools/sub_agents/instructions/document_instructions.ts
  • services/platform/convex/lib/create_document_agent.ts
  • services/platform/convex/lib/create_chat_agent.ts
  • services/platform/convex/lib/create_web_agent.ts
📚 Learning: 2025-12-20T13:38:13.773Z
Learnt from: larryro
Repo: tale-project/tale PR: 30
File: services/platform/convex/model/chat_agent/chat_with_agent.ts:130-144
Timestamp: 2025-12-20T13:38:13.773Z
Learning: In services/platform/convex/model/chat_agent/chat_with_agent.ts, image fileIds are intentionally displayed as `*(fileId: ${attachment.fileId})*` in the markdown because the AI needs to reference them from thread history for re-analysis using the image tool. This is a business/developer tool, not consumer-facing, so technical metadata visibility is acceptable.

Applied to files:

  • services/platform/convex/agent_tools/sub_agents/instructions/document_instructions.ts
  • services/platform/convex/agent_tools/sub_agents/document_assistant_tool.ts
  • services/platform/convex/lib/create_chat_agent.ts
📚 Learning: 2025-07-20T08:40:24.693Z
Learnt from: CR
Repo: talecorp/poc PR: 0
File: .cursor/rules/ai.mdc:0-0
Timestamp: 2025-07-20T08:40:24.693Z
Learning: Applies to **/app/api/**/*.ts : For text generation, use the `generateObject` or similar functions from the AI SDK

Applied to files:

  • services/platform/convex/agent_tools/sub_agents/instructions/document_instructions.ts
  • services/platform/convex/lib/create_document_agent.ts
  • services/platform/convex/lib/create_chat_agent.ts
  • services/platform/convex/lib/create_web_agent.ts
📚 Learning: 2025-12-26T03:04:07.995Z
Learnt from: larryro
Repo: tale-project/tale PR: 35
File: services/platform/convex/approvals.ts:51-62
Timestamp: 2025-12-26T03:04:07.995Z
Learning: In Convex approvals API (services/platform/convex/approvals.ts), continue the pattern of maintaining separate internalQuery functions for internal vs public API access (e.g., getApprovalInternal vs getApprovalById) even if implementations are identical. This separation preserves the ability to diverge access control patterns in the future without breaking call sites. Apply this guideline broadly to the Convex-related API files under services/platform/convex/, using the pattern services/platform/convex/**/*.ts to cover similar modules. Ensure new or refactored internal/public wrappers follow this convention and document intent where access rules may evolve.

Applied to files:

  • services/platform/convex/agent_tools/sub_agents/instructions/document_instructions.ts
  • services/platform/convex/agent_tools/sub_agents/instructions/integration_instructions.ts
  • services/platform/convex/lib/create_integration_agent.ts
  • services/platform/convex/agent_tools/sub_agents/document_assistant_tool.ts
  • services/platform/convex/lib/create_document_agent.ts
  • services/platform/convex/agent_tools/sub_agents/instructions/web_instructions.ts
  • services/platform/convex/agent_tools/sub_agents/web_assistant_tool.ts
  • services/platform/convex/lib/create_chat_agent.ts
  • services/platform/convex/agent_tools/sub_agents/integration_assistant_tool.ts
  • services/platform/convex/lib/create_web_agent.ts
  • services/platform/convex/agent_tools/tool_registry.ts
📚 Learning: 2025-12-30T03:24:33.770Z
Learnt from: larryro
Repo: tale-project/tale PR: 36
File: services/platform/convex/wf_step_defs.ts:33-39
Timestamp: 2025-12-30T03:24:33.770Z
Learning: In Convex API files under services/platform/convex (e.g., wf_step_defs.ts and peers) refrain from delegating trivial single-line database calls like ctx.db.get(id) to model helpers. Use direct calls for simple operations with no extra business logic. Reserve model helpers for complex tasks (ordering, filtering, validation, transformation). This guideline applies to all .ts files in this Convex API area.

Applied to files:

  • services/platform/convex/agent_tools/sub_agents/instructions/document_instructions.ts
  • services/platform/convex/agent_tools/sub_agents/instructions/integration_instructions.ts
  • services/platform/convex/lib/create_integration_agent.ts
  • services/platform/convex/agent_tools/sub_agents/document_assistant_tool.ts
  • services/platform/convex/lib/create_document_agent.ts
  • services/platform/convex/agent_tools/sub_agents/instructions/web_instructions.ts
  • services/platform/convex/agent_tools/sub_agents/web_assistant_tool.ts
  • services/platform/convex/lib/create_chat_agent.ts
  • services/platform/convex/agent_tools/sub_agents/integration_assistant_tool.ts
  • services/platform/convex/lib/create_web_agent.ts
  • services/platform/convex/agent_tools/tool_registry.ts
📚 Learning: 2025-12-30T03:05:07.814Z
Learnt from: larryro
Repo: tale-project/tale PR: 36
File: services/platform/convex/agent_tools/database/helpers/schema_definitions.ts:238-242
Timestamp: 2025-12-30T03:05:07.814Z
Learning: In any file under services/platform/convex/agent_tools (e.g., database/helpers/schema_definitions.ts) prefer runtime validation of identifiers like tableName coming from LLM/user input over relying on TypeScript type restrictions alone. Implement validation at call boundaries that returns descriptive, user-friendly errors (e.g., listing available options) instead of returning null or failing at compile time. This approach supports graceful error handling and better UX for misinput.

Applied to files:

  • services/platform/convex/agent_tools/sub_agents/instructions/document_instructions.ts
  • services/platform/convex/agent_tools/sub_agents/instructions/integration_instructions.ts
  • services/platform/convex/agent_tools/sub_agents/document_assistant_tool.ts
  • services/platform/convex/agent_tools/sub_agents/instructions/web_instructions.ts
  • services/platform/convex/agent_tools/sub_agents/web_assistant_tool.ts
  • services/platform/convex/agent_tools/sub_agents/integration_assistant_tool.ts
  • services/platform/convex/agent_tools/tool_registry.ts
📚 Learning: 2025-12-30T06:21:13.183Z
Learnt from: larryro
Repo: tale-project/tale PR: 37
File: services/platform/convex/model/documents/validators.ts:89-102
Timestamp: 2025-12-30T06:21:13.183Z
Learning: Do not flag a missing trailing newline for TypeScript files in code reviews. POSIX text files should end with a trailing newline and Prettier (or your formatter) will enforce this. Treat the trailing newline as a non-issue in reviews for all TS files.

Applied to files:

  • services/platform/convex/agent_tools/sub_agents/instructions/document_instructions.ts
  • services/platform/convex/agent_tools/sub_agents/instructions/integration_instructions.ts
  • services/platform/convex/lib/create_integration_agent.ts
  • services/platform/convex/agent_tools/sub_agents/document_assistant_tool.ts
  • services/platform/convex/lib/create_document_agent.ts
  • services/platform/convex/agent_tools/sub_agents/instructions/web_instructions.ts
  • services/platform/convex/agent_tools/sub_agents/web_assistant_tool.ts
  • services/platform/convex/lib/create_chat_agent.ts
  • services/platform/convex/agent_tools/sub_agents/integration_assistant_tool.ts
  • services/platform/convex/lib/create_web_agent.ts
  • services/platform/convex/agent_tools/tool_registry.ts
📚 Learning: 2025-11-30T12:29:39.745Z
Learnt from: CR
Repo: tale-project/poc2 PR: 0
File: .cursor/rules/workspace_rules.mdc:0-0
Timestamp: 2025-11-30T12:29:39.745Z
Learning: Applies to convex/*.ts : Split existing Convex modules that export multiple functions into separate files with one function per file, except for explicitly designated thin wrapper modules

Applied to files:

  • services/platform/convex/lib/create_integration_agent.ts
📚 Learning: 2025-11-30T12:29:39.745Z
Learnt from: CR
Repo: tale-project/poc2 PR: 0
File: .cursor/rules/workspace_rules.mdc:0-0
Timestamp: 2025-11-30T12:29:39.745Z
Learning: Applies to services/**/convex/*.ts : Thin wrapper API modules in services may export multiple Convex functions as thin wrappers that delegate to model helpers, must use snake_case file names and camelCase export names, and must not contain business logic

Applied to files:

  • services/platform/convex/lib/create_integration_agent.ts
📚 Learning: 2025-12-30T03:05:13.035Z
Learnt from: larryro
Repo: tale-project/tale PR: 36
File: services/platform/convex/agent_tools/database/helpers/schema_definitions.ts:238-242
Timestamp: 2025-12-30T03:05:13.035Z
Learning: For AI agent tool APIs in services/platform/convex/agent_tools that receive tableName or similar identifiers from runtime LLM/user input, prefer runtime validation with descriptive error messages over compile-time TypeScript type restrictions. The pattern of returning null and handling validation at the caller level with helpful error messages (listing available options) is the preferred approach for graceful error handling.

Applied to files:

  • services/platform/convex/lib/create_chat_agent.ts
📚 Learning: 2025-12-30T03:47:44.914Z
Learnt from: larryro
Repo: tale-project/tale PR: 36
File: services/platform/convex/agent_tools/workflows/workflow_read_tool.ts:127-144
Timestamp: 2025-12-30T03:47:44.914Z
Learning: In AI agent tool APIs in services/platform/convex/agent_tools/workflows, using `any` type for return data that varies significantly based on runtime conditions (e.g., step structures in workflow_read_tool.ts that differ by stepType: LLM, code, condition, etc.) is acceptable when the caller (AI agent) treats the data as opaque for inspection. Strict typing with complex union types provides limited practical benefit in these cases.

Applied to files:

  • services/platform/convex/lib/create_chat_agent.ts
🧬 Code graph analysis (6)
services/platform/convex/lib/create_integration_agent.ts (4)
services/platform/convex/lib/debug_log.ts (1)
  • createDebugLog (27-39)
services/platform/convex/agent_tools/tool_registry.ts (1)
  • ToolName (100-100)
services/platform/convex/lib/create_agent_config.ts (1)
  • createAgentConfig (15-105)
services/platform/convex/agent_tools/sub_agents/instructions/integration_instructions.ts (1)
  • INTEGRATION_ASSISTANT_INSTRUCTIONS (8-53)
services/platform/convex/agent_tools/sub_agents/document_assistant_tool.ts (2)
services/platform/convex/lib/create_document_agent.ts (1)
  • createDocumentAgent (17-43)
services/platform/convex/agent_tools/types.ts (1)
  • ToolDefinition (19-22)
services/platform/convex/lib/create_document_agent.ts (4)
services/platform/convex/lib/debug_log.ts (1)
  • createDebugLog (27-39)
services/platform/convex/agent_tools/tool_registry.ts (1)
  • ToolName (100-100)
services/platform/convex/lib/create_agent_config.ts (1)
  • createAgentConfig (15-105)
services/platform/convex/agent_tools/sub_agents/instructions/document_instructions.ts (1)
  • DOCUMENT_ASSISTANT_INSTRUCTIONS (8-46)
services/platform/convex/agent_tools/sub_agents/web_assistant_tool.ts (2)
services/platform/convex/lib/create_web_agent.ts (1)
  • createWebAgent (17-37)
services/platform/convex/agent_tools/types.ts (1)
  • ToolDefinition (19-22)
services/platform/convex/lib/create_web_agent.ts (4)
services/platform/convex/lib/debug_log.ts (1)
  • createDebugLog (27-39)
services/platform/convex/agent_tools/tool_registry.ts (1)
  • ToolName (100-100)
services/platform/convex/lib/create_agent_config.ts (1)
  • createAgentConfig (15-105)
services/platform/convex/agent_tools/sub_agents/instructions/web_instructions.ts (1)
  • WEB_ASSISTANT_INSTRUCTIONS (8-38)
services/platform/convex/agent_tools/tool_registry.ts (3)
services/platform/convex/agent_tools/sub_agents/web_assistant_tool.ts (1)
  • webAssistantTool (14-130)
services/platform/convex/agent_tools/sub_agents/document_assistant_tool.ts (1)
  • documentAssistantTool (14-139)
services/platform/convex/agent_tools/sub_agents/integration_assistant_tool.ts (1)
  • integrationAssistantTool (19-180)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Build Docker Image
🔇 Additional comments (9)
services/platform/convex/agent_tools/sub_agents/instructions/web_instructions.ts (1)

8-38: LGTM! Clear and actionable instructions.

The web assistant instructions are well-structured and emphasize the critical search → fetch → summarize workflow. The explicit reminder about fetching URLs to get actual content (Line 22) is particularly helpful for preventing common mistakes.

services/platform/convex/agent_tools/tool_registry.ts (1)

30-32: LGTM! Sub-agent tools properly registered.

The new sub-agent tools are correctly added to both TOOL_NAMES and TOOL_REGISTRY arrays, maintaining consistency between the two. The imports follow the existing grouping pattern by feature area, and the new entries are added in a logical order (web, document, integration).

Also applies to: 62-64, 92-94

services/platform/convex/lib/create_document_agent.ts (1)

1-43: LGTM!

The agent factory follows the established pattern from create_web_agent.ts consistently. Good use of implicit typing, named exports, and clean structure with appropriate defaults.

services/platform/convex/agent_tools/sub_agents/instructions/document_instructions.ts (1)

1-46: LGTM!

Well-structured instructions with clear guidance for each tool capability. The documentation aligns with the tools configured in create_document_agent.ts.

services/platform/convex/agent_tools/sub_agents/web_assistant_tool.ts (2)

14-130: LGTM on tool structure and error handling.

Clean implementation with proper validation, structured error responses, and diagnostic logging. The tool definition pattern aligns with ToolDefinition interface.


94-106: Add cleanup for sub-thread after generateText call.

Sub-threads created at line 95 are not being cleaned up after use. While threads are isolated, they will accumulate in the database over time. Apply the same cleanup pattern used in analyze_image.ts and analyze_image_by_url.ts: add a try/catch block after the generateText call that archives the sub-thread via updateThread with status: 'archived'. This should be non-fatal (caught and logged) to avoid interrupting the result.

Note: This pattern is missing from all sub-agent tools (integration_assistant_tool.ts, document_assistant_tool.ts, workflow_assistant_tool.ts as well).

⛔ Skipped due to learnings
Learnt from: larryro
Repo: tale-project/tale PR: 30
File: services/platform/convex/model/chat_agent/chat_with_agent.ts:130-144
Timestamp: 2025-12-20T13:38:13.773Z
Learning: In services/platform/convex/model/chat_agent/chat_with_agent.ts, image fileIds are intentionally displayed as `*(fileId: ${attachment.fileId})*` in the markdown because the AI needs to reference them from thread history for re-analysis using the image tool. This is a business/developer tool, not consumer-facing, so technical metadata visibility is acceptable.
Learnt from: larryro
Repo: tale-project/tale PR: 36
File: services/platform/convex/agent_tools/database/helpers/schema_definitions.ts:238-242
Timestamp: 2025-12-30T03:05:13.035Z
Learning: For AI agent tool APIs in services/platform/convex/agent_tools that receive tableName or similar identifiers from runtime LLM/user input, prefer runtime validation with descriptive error messages over compile-time TypeScript type restrictions. The pattern of returning null and handling validation at the caller level with helpful error messages (listing available options) is the preferred approach for graceful error handling.
services/platform/convex/lib/create_chat_agent.ts (2)

28-41: LGTM on tool set reorganization.

The categorization between direct tools (fast, bounded output) and sub-agents (context isolation) is clear and well-documented. Comments effectively explain the rationale for the delegation pattern.


77-103: LGTM on instruction updates.

The SUB-AGENT DELEGATION section provides clear guidance on when to use each sub-agent. The instructions align with the available tools and maintain consistency with the tool descriptions in each sub-agent file.

services/platform/convex/agent_tools/sub_agents/document_assistant_tool.ts (1)

1-139: LGTM!

Clean implementation that follows the established sub-agent tool pattern. Proper validation, structured error handling, and diagnostic logging. The argument schema appropriately covers the various document operation scenarios (parsing, generation, image analysis).

Comment thread services/platform/convex/lib/create_integration_agent.ts
Comment thread services/platform/convex/lib/create_web_agent.ts
@larryro larryro force-pushed the claude/refactor-chat-agent-subagents-TYYGe branch from 96123d3 to f81143c Compare January 4, 2026 15:13
@larryro
Copy link
Copy Markdown
Collaborator Author

larryro commented Jan 4, 2026

@coderabbitai full review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jan 4, 2026

✅ Actions performed

Full review triggered.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 20

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
services/platform/convex/model/chat_agent/context_management/context_priority.ts (2)

7-8: Update comment to reflect expanded system context.

The comment still refers to "Thread ID" as the highest priority, but the implementation now includes both thread ID and current time as "system_info" (Line 203-205). Update the comment to reflect this expanded context.

🔎 Suggested fix
 * PRIORITY LEVELS (highest to lowest):
- * 1. Thread ID - Always needed for tool context
+ * 1. System Info - Thread ID and current time for tool context
  * 2. Current user message - The query being answered

27-27: Consider renaming THREAD_ID enum value to SYSTEM_INFO.

The enum value ContextPriority.THREAD_ID is now used for system_info content that includes both thread ID and current time (Line 203-205). The name no longer accurately reflects its purpose. Renaming to SYSTEM_INFO would improve code clarity.

🔎 Proposed refactor
 export enum ContextPriority {
-  THREAD_ID = 1,
+  SYSTEM_INFO = 1,
   CURRENT_USER_MESSAGE = 2,

This would require updating references in Line 204 and elsewhere:

     createPrioritizedContext(
       'system_info',
-      ContextPriority.THREAD_ID,
+      ContextPriority.SYSTEM_INFO,
♻️ Duplicate comments (3)
services/platform/convex/lib/create_document_agent.ts (1)

22-28: Consider implicit typing for convexToolNames.

Similar to the web agent, the explicit ToolName[] annotation could be omitted per the coding guidelines. This pattern is consistent across all agent factories but deviates from the implicit-typing guideline.

🔎 Optional change to use implicit typing
-  const convexToolNames: ToolName[] = [
+  const convexToolNames = [
     'pdf',
     'image',
     'docx',
     'pptx',
     'generate_excel',
-  ];
+  ] as const satisfies ToolName[];
services/platform/convex/agent_tools/sub_agents/integration_assistant_tool.ts (2)

96-112: Role check bypassed when only threadId is provided.

As noted in previous review, the role validation only executes when userId is truthy (line 97). If the tool is invoked with only a threadId (allowed per line 88), the role check is completely skipped, potentially allowing unauthorized access to integration operations.

🔎 Proposed fix

Require userId for role-based access control:

       // Check user role - only admin and developer can use this tool
-      if (userId) {
-        const userRole = await ctx.runQuery(internal.member.getMemberRoleInternal, {
-          userId,
-          organizationId,
-        });
-
-        const normalizedRole = (userRole ?? 'member').toLowerCase();
-        if (!ALLOWED_ROLES.includes(normalizedRole as (typeof ALLOWED_ROLES)[number])) {
-          console.log('[integration_assistant_tool] Access denied for role:', normalizedRole);
-          return {
-            success: false,
-            response: '',
-            error: `Access denied: The integration assistant is only available to users with admin or developer roles. Your current role is "${normalizedRole}".`,
-          };
-        }
+      if (!userId) {
+        return {
+          success: false,
+          response: '',
+          error: 'userId is required for integration_assistant to verify role permissions',
+        };
       }
+
+      const userRole = await ctx.runQuery(internal.member.getMemberRoleInternal, {
+        userId,
+        organizationId,
+      });
+
+      const normalizedRole = (userRole ?? 'member').toLowerCase();
+      if (!ALLOWED_ROLES.includes(normalizedRole as (typeof ALLOWED_ROLES)[number])) {
+        console.log('[integration_assistant_tool] Access denied for role:', normalizedRole);
+        return {
+          success: false,
+          response: '',
+          error: `Access denied: The integration assistant is only available to users with admin or developer roles. Your current role is "${normalizedRole}".`,
+        };
+      }

200-216: Consider a more reliable approval detection mechanism.

As noted in previous review, the regex-based approval detection (lines 201-204) is fragile and could produce false positives/negatives. While functional for now, consider having the integration agent return structured metadata rather than parsing natural language text if approval tracking is critical.

📜 Review details

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro (Legacy)

📥 Commits

Reviewing files that changed from the base of the PR and between 1b129cc and f81143c.

⛔ Files ignored due to path filters (1)
  • services/platform/convex/_generated/api.d.ts is excluded by !**/_generated/**
📒 Files selected for processing (36)
  • compose.yml
  • services/platform/convex/agent_tools/crawler/helpers/search_and_fetch.ts
  • services/platform/convex/agent_tools/crawler/helpers/types.ts
  • services/platform/convex/agent_tools/crawler/web_read_tool.ts
  • services/platform/convex/agent_tools/integrations/execute_batch_integration_internal.ts
  • services/platform/convex/agent_tools/integrations/integration_batch_tool.ts
  • services/platform/convex/agent_tools/integrations/integration_introspect_tool.ts
  • services/platform/convex/agent_tools/integrations/types.ts
  • services/platform/convex/agent_tools/rag/rag_search_tool.ts
  • services/platform/convex/agent_tools/sub_agents/document_assistant_tool.ts
  • services/platform/convex/agent_tools/sub_agents/helpers/format_integrations.ts
  • services/platform/convex/agent_tools/sub_agents/helpers/get_or_create_sub_thread.ts
  • services/platform/convex/agent_tools/sub_agents/helpers/types.ts
  • services/platform/convex/agent_tools/sub_agents/instructions/document_instructions.ts
  • services/platform/convex/agent_tools/sub_agents/instructions/integration_instructions.ts
  • services/platform/convex/agent_tools/sub_agents/instructions/web_instructions.ts
  • services/platform/convex/agent_tools/sub_agents/integration_assistant_tool.ts
  • services/platform/convex/agent_tools/sub_agents/web_assistant_tool.ts
  • services/platform/convex/agent_tools/sub_agents/workflow_assistant_tool.ts
  • services/platform/convex/agent_tools/tool_registry.ts
  • services/platform/convex/chat_agent.ts
  • services/platform/convex/lib/create_agent_config.ts
  • services/platform/convex/lib/create_chat_agent.ts
  • services/platform/convex/lib/create_document_agent.ts
  • services/platform/convex/lib/create_integration_agent.ts
  • services/platform/convex/lib/create_web_agent.ts
  • services/platform/convex/message_metadata.ts
  • services/platform/convex/model/chat_agent/context_management/context_priority.ts
  • services/platform/convex/model/chat_agent/generate_agent_response.ts
  • services/platform/convex/model/chat_agent/on_chat_complete.ts
  • services/platform/convex/schema.ts
  • services/rag/app/config.py
  • services/rag/app/main.py
  • services/rag/app/services/cognee/cleanup.py
  • services/rag/app/services/cognee/config.py
  • services/rag/app/services/cognee/service.py
🧰 Additional context used
📓 Path-based instructions (3)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.{ts,tsx}: USE implicit typing whenever possible in TypeScript
DO NOT use type casting. Avoid any, and unknown whenever possible in TypeScript

Files:

  • services/platform/convex/lib/create_integration_agent.ts
  • services/platform/convex/agent_tools/sub_agents/instructions/integration_instructions.ts
  • services/platform/convex/schema.ts
  • services/platform/convex/agent_tools/sub_agents/instructions/web_instructions.ts
  • services/platform/convex/agent_tools/sub_agents/integration_assistant_tool.ts
  • services/platform/convex/agent_tools/integrations/integration_introspect_tool.ts
  • services/platform/convex/agent_tools/crawler/helpers/types.ts
  • services/platform/convex/agent_tools/integrations/integration_batch_tool.ts
  • services/platform/convex/lib/create_document_agent.ts
  • services/platform/convex/agent_tools/integrations/types.ts
  • services/platform/convex/agent_tools/sub_agents/helpers/format_integrations.ts
  • services/platform/convex/lib/create_web_agent.ts
  • services/platform/convex/agent_tools/sub_agents/document_assistant_tool.ts
  • services/platform/convex/agent_tools/tool_registry.ts
  • services/platform/convex/chat_agent.ts
  • services/platform/convex/model/chat_agent/context_management/context_priority.ts
  • services/platform/convex/lib/create_agent_config.ts
  • services/platform/convex/agent_tools/sub_agents/instructions/document_instructions.ts
  • services/platform/convex/agent_tools/sub_agents/web_assistant_tool.ts
  • services/platform/convex/lib/create_chat_agent.ts
  • services/platform/convex/model/chat_agent/generate_agent_response.ts
  • services/platform/convex/agent_tools/rag/rag_search_tool.ts
  • services/platform/convex/message_metadata.ts
  • services/platform/convex/agent_tools/crawler/helpers/search_and_fetch.ts
  • services/platform/convex/agent_tools/sub_agents/helpers/get_or_create_sub_thread.ts
  • services/platform/convex/agent_tools/sub_agents/helpers/types.ts
  • services/platform/convex/agent_tools/crawler/web_read_tool.ts
  • services/platform/convex/model/chat_agent/on_chat_complete.ts
  • services/platform/convex/agent_tools/integrations/execute_batch_integration_internal.ts
  • services/platform/convex/agent_tools/sub_agents/workflow_assistant_tool.ts
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.{ts,tsx,js,jsx}: ALWAYS put imports at the top and exports at the bottom. Keep them sorted correctly
PREFER named exports. AVOID default exports (only if needed)

Files:

  • services/platform/convex/lib/create_integration_agent.ts
  • services/platform/convex/agent_tools/sub_agents/instructions/integration_instructions.ts
  • services/platform/convex/schema.ts
  • services/platform/convex/agent_tools/sub_agents/instructions/web_instructions.ts
  • services/platform/convex/agent_tools/sub_agents/integration_assistant_tool.ts
  • services/platform/convex/agent_tools/integrations/integration_introspect_tool.ts
  • services/platform/convex/agent_tools/crawler/helpers/types.ts
  • services/platform/convex/agent_tools/integrations/integration_batch_tool.ts
  • services/platform/convex/lib/create_document_agent.ts
  • services/platform/convex/agent_tools/integrations/types.ts
  • services/platform/convex/agent_tools/sub_agents/helpers/format_integrations.ts
  • services/platform/convex/lib/create_web_agent.ts
  • services/platform/convex/agent_tools/sub_agents/document_assistant_tool.ts
  • services/platform/convex/agent_tools/tool_registry.ts
  • services/platform/convex/chat_agent.ts
  • services/platform/convex/model/chat_agent/context_management/context_priority.ts
  • services/platform/convex/lib/create_agent_config.ts
  • services/platform/convex/agent_tools/sub_agents/instructions/document_instructions.ts
  • services/platform/convex/agent_tools/sub_agents/web_assistant_tool.ts
  • services/platform/convex/lib/create_chat_agent.ts
  • services/platform/convex/model/chat_agent/generate_agent_response.ts
  • services/platform/convex/agent_tools/rag/rag_search_tool.ts
  • services/platform/convex/message_metadata.ts
  • services/platform/convex/agent_tools/crawler/helpers/search_and_fetch.ts
  • services/platform/convex/agent_tools/sub_agents/helpers/get_or_create_sub_thread.ts
  • services/platform/convex/agent_tools/sub_agents/helpers/types.ts
  • services/platform/convex/agent_tools/crawler/web_read_tool.ts
  • services/platform/convex/model/chat_agent/on_chat_complete.ts
  • services/platform/convex/agent_tools/integrations/execute_batch_integration_internal.ts
  • services/platform/convex/agent_tools/sub_agents/workflow_assistant_tool.ts
**/convex/**/*.{ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

**/convex/**/*.{ts,tsx}: CONSIDER TO use rate limiting and action caching in Convex
DO NOT use .collect(), use for await (const ... of ...) instead in Convex

Files:

  • services/platform/convex/lib/create_integration_agent.ts
  • services/platform/convex/agent_tools/sub_agents/instructions/integration_instructions.ts
  • services/platform/convex/schema.ts
  • services/platform/convex/agent_tools/sub_agents/instructions/web_instructions.ts
  • services/platform/convex/agent_tools/sub_agents/integration_assistant_tool.ts
  • services/platform/convex/agent_tools/integrations/integration_introspect_tool.ts
  • services/platform/convex/agent_tools/crawler/helpers/types.ts
  • services/platform/convex/agent_tools/integrations/integration_batch_tool.ts
  • services/platform/convex/lib/create_document_agent.ts
  • services/platform/convex/agent_tools/integrations/types.ts
  • services/platform/convex/agent_tools/sub_agents/helpers/format_integrations.ts
  • services/platform/convex/lib/create_web_agent.ts
  • services/platform/convex/agent_tools/sub_agents/document_assistant_tool.ts
  • services/platform/convex/agent_tools/tool_registry.ts
  • services/platform/convex/chat_agent.ts
  • services/platform/convex/model/chat_agent/context_management/context_priority.ts
  • services/platform/convex/lib/create_agent_config.ts
  • services/platform/convex/agent_tools/sub_agents/instructions/document_instructions.ts
  • services/platform/convex/agent_tools/sub_agents/web_assistant_tool.ts
  • services/platform/convex/lib/create_chat_agent.ts
  • services/platform/convex/model/chat_agent/generate_agent_response.ts
  • services/platform/convex/agent_tools/rag/rag_search_tool.ts
  • services/platform/convex/message_metadata.ts
  • services/platform/convex/agent_tools/crawler/helpers/search_and_fetch.ts
  • services/platform/convex/agent_tools/sub_agents/helpers/get_or_create_sub_thread.ts
  • services/platform/convex/agent_tools/sub_agents/helpers/types.ts
  • services/platform/convex/agent_tools/crawler/web_read_tool.ts
  • services/platform/convex/model/chat_agent/on_chat_complete.ts
  • services/platform/convex/agent_tools/integrations/execute_batch_integration_internal.ts
  • services/platform/convex/agent_tools/sub_agents/workflow_assistant_tool.ts
🧠 Learnings (32)
📚 Learning: 2025-12-26T03:04:07.995Z
Learnt from: larryro
Repo: tale-project/tale PR: 35
File: services/platform/convex/approvals.ts:51-62
Timestamp: 2025-12-26T03:04:07.995Z
Learning: In Convex approvals API (services/platform/convex/approvals.ts), continue the pattern of maintaining separate internalQuery functions for internal vs public API access (e.g., getApprovalInternal vs getApprovalById) even if implementations are identical. This separation preserves the ability to diverge access control patterns in the future without breaking call sites. Apply this guideline broadly to the Convex-related API files under services/platform/convex/, using the pattern services/platform/convex/**/*.ts to cover similar modules. Ensure new or refactored internal/public wrappers follow this convention and document intent where access rules may evolve.

Applied to files:

  • services/platform/convex/lib/create_integration_agent.ts
  • services/platform/convex/agent_tools/sub_agents/instructions/integration_instructions.ts
  • services/platform/convex/schema.ts
  • services/platform/convex/agent_tools/sub_agents/instructions/web_instructions.ts
  • services/platform/convex/agent_tools/sub_agents/integration_assistant_tool.ts
  • services/platform/convex/agent_tools/integrations/integration_introspect_tool.ts
  • services/platform/convex/agent_tools/crawler/helpers/types.ts
  • services/platform/convex/agent_tools/integrations/integration_batch_tool.ts
  • services/platform/convex/lib/create_document_agent.ts
  • services/platform/convex/agent_tools/integrations/types.ts
  • services/platform/convex/agent_tools/sub_agents/helpers/format_integrations.ts
  • services/platform/convex/lib/create_web_agent.ts
  • services/platform/convex/agent_tools/sub_agents/document_assistant_tool.ts
  • services/platform/convex/agent_tools/tool_registry.ts
  • services/platform/convex/chat_agent.ts
  • services/platform/convex/model/chat_agent/context_management/context_priority.ts
  • services/platform/convex/lib/create_agent_config.ts
  • services/platform/convex/agent_tools/sub_agents/instructions/document_instructions.ts
  • services/platform/convex/agent_tools/sub_agents/web_assistant_tool.ts
  • services/platform/convex/lib/create_chat_agent.ts
  • services/platform/convex/model/chat_agent/generate_agent_response.ts
  • services/platform/convex/agent_tools/rag/rag_search_tool.ts
  • services/platform/convex/message_metadata.ts
  • services/platform/convex/agent_tools/crawler/helpers/search_and_fetch.ts
  • services/platform/convex/agent_tools/sub_agents/helpers/get_or_create_sub_thread.ts
  • services/platform/convex/agent_tools/sub_agents/helpers/types.ts
  • services/platform/convex/agent_tools/crawler/web_read_tool.ts
  • services/platform/convex/model/chat_agent/on_chat_complete.ts
  • services/platform/convex/agent_tools/integrations/execute_batch_integration_internal.ts
  • services/platform/convex/agent_tools/sub_agents/workflow_assistant_tool.ts
📚 Learning: 2025-11-30T03:53:00.316Z
Learnt from: CR
Repo: tale-project/poc2 PR: 0
File: .cursor/rules/convex_rules.mdc:0-0
Timestamp: 2025-11-30T03:53:00.316Z
Learning: Applies to convex/**/*.ts : When using the `Array` type, always define arrays as `const array: Array<T> = [...]`

Applied to files:

  • services/platform/convex/lib/create_integration_agent.ts
  • services/platform/convex/lib/create_web_agent.ts
📚 Learning: 2025-12-30T03:05:13.035Z
Learnt from: larryro
Repo: tale-project/tale PR: 36
File: services/platform/convex/agent_tools/database/helpers/schema_definitions.ts:238-242
Timestamp: 2025-12-30T03:05:13.035Z
Learning: For AI agent tool APIs in services/platform/convex/agent_tools that receive tableName or similar identifiers from runtime LLM/user input, prefer runtime validation with descriptive error messages over compile-time TypeScript type restrictions. The pattern of returning null and handling validation at the caller level with helpful error messages (listing available options) is the preferred approach for graceful error handling.

Applied to files:

  • services/platform/convex/lib/create_integration_agent.ts
  • services/platform/convex/lib/create_web_agent.ts
  • services/platform/convex/chat_agent.ts
  • services/platform/convex/lib/create_agent_config.ts
  • services/platform/convex/lib/create_chat_agent.ts
📚 Learning: 2025-12-30T03:47:44.914Z
Learnt from: larryro
Repo: tale-project/tale PR: 36
File: services/platform/convex/agent_tools/workflows/workflow_read_tool.ts:127-144
Timestamp: 2025-12-30T03:47:44.914Z
Learning: In AI agent tool APIs in services/platform/convex/agent_tools/workflows, using `any` type for return data that varies significantly based on runtime conditions (e.g., step structures in workflow_read_tool.ts that differ by stepType: LLM, code, condition, etc.) is acceptable when the caller (AI agent) treats the data as opaque for inspection. Strict typing with complex union types provides limited practical benefit in these cases.

Applied to files:

  • services/platform/convex/lib/create_integration_agent.ts
  • services/platform/convex/lib/create_web_agent.ts
  • services/platform/convex/lib/create_chat_agent.ts
  • services/platform/convex/model/chat_agent/generate_agent_response.ts
  • services/platform/convex/agent_tools/sub_agents/helpers/types.ts
  • services/platform/convex/agent_tools/sub_agents/workflow_assistant_tool.ts
📚 Learning: 2024-10-08T16:22:15.228Z
Learnt from: larryro
Repo: talecorp/tale PR: 1297
File: apps/app/app/[locale]/(protected)/merchant/activate-account/onboarding/stripe-embedded-account-onboarding.tsx:8-11
Timestamp: 2024-10-08T16:22:15.228Z
Learning: In this project, prefer relying on TypeScript's type inference instead of adding explicit type annotations when they are not necessary.

Applied to files:

  • services/platform/convex/lib/create_integration_agent.ts
  • services/platform/convex/lib/create_web_agent.ts
📚 Learning: 2025-12-15T14:44:09.823Z
Learnt from: larryro
Repo: tale-project/tale PR: 18
File: services/platform/convex/workflow/actions/conversation/conversation_action.ts:47-98
Timestamp: 2025-12-15T14:44:09.823Z
Learning: In Convex action files (services/platform/convex/workflow/actions/**/), maintaining a separate TypeScript type alongside the parametersValidator is an acceptable pattern when documented. The TypeScript type provides IDE support and compile-time checking, while the validator provides runtime validation. This intentional separation should be documented with a comment explaining the design choice.

Applied to files:

  • services/platform/convex/lib/create_integration_agent.ts
  • services/platform/convex/lib/create_web_agent.ts
  • services/platform/convex/agent_tools/sub_agents/instructions/document_instructions.ts
📚 Learning: 2025-11-30T03:53:00.316Z
Learnt from: CR
Repo: tale-project/poc2 PR: 0
File: .cursor/rules/convex_rules.mdc:0-0
Timestamp: 2025-11-30T03:53:00.316Z
Learning: Applies to convex/**/*.ts : Always use `as const` for string literals in discriminated union types

Applied to files:

  • services/platform/convex/lib/create_integration_agent.ts
📚 Learning: 2025-10-11T11:46:02.452Z
Learnt from: CR
Repo: talecorp/poc2 PR: 0
File: .cursorrules:0-0
Timestamp: 2025-10-11T11:46:02.452Z
Learning: Applies to convex/**/*.ts : Convex file names must be snake_case and exported function names must be camelCase

Applied to files:

  • services/platform/convex/lib/create_integration_agent.ts
  • services/platform/convex/lib/create_web_agent.ts
📚 Learning: 2025-10-03T11:34:20.628Z
Learnt from: CR
Repo: talecorp/poc2 PR: 0
File: .cursor/rules/convex_rules.mdc:0-0
Timestamp: 2025-10-03T11:34:20.628Z
Learning: Applies to convex/**/*.ts : Use as const for string literals in discriminated unions

Applied to files:

  • services/platform/convex/lib/create_integration_agent.ts
📚 Learning: 2025-11-30T03:53:00.316Z
Learnt from: CR
Repo: tale-project/poc2 PR: 0
File: .cursor/rules/convex_rules.mdc:0-0
Timestamp: 2025-11-30T03:53:00.316Z
Learning: Applies to convex/**/*.ts : Be strict with types, particularly around IDs of documents; use `Id<'tableName'>` rather than `string` for function arguments and returns

Applied to files:

  • services/platform/convex/lib/create_integration_agent.ts
📚 Learning: 2025-12-30T03:53:06.120Z
Learnt from: larryro
Repo: tale-project/tale PR: 36
File: services/platform/convex/workflow_assistant_agent.ts:94-107
Timestamp: 2025-12-30T03:53:06.120Z
Learning: In services/platform/convex/workflow_assistant_agent.ts, using `any` type for step parameters during toonification (compact representation) is acceptable when step structures vary significantly by stepType (llm, condition, action, loop). The sanitization approach extracts only needed fields for context, and strict typing with complex discriminated unions would add maintenance burden without practical benefit since the data is only used for compact representation, not type-specific processing.

Applied to files:

  • services/platform/convex/lib/create_integration_agent.ts
  • services/platform/convex/lib/create_web_agent.ts
📚 Learning: 2025-12-30T03:24:33.770Z
Learnt from: larryro
Repo: tale-project/tale PR: 36
File: services/platform/convex/wf_step_defs.ts:33-39
Timestamp: 2025-12-30T03:24:33.770Z
Learning: In Convex API files under services/platform/convex (e.g., wf_step_defs.ts and peers) refrain from delegating trivial single-line database calls like ctx.db.get(id) to model helpers. Use direct calls for simple operations with no extra business logic. Reserve model helpers for complex tasks (ordering, filtering, validation, transformation). This guideline applies to all .ts files in this Convex API area.

Applied to files:

  • services/platform/convex/lib/create_integration_agent.ts
  • services/platform/convex/agent_tools/sub_agents/instructions/integration_instructions.ts
  • services/platform/convex/schema.ts
  • services/platform/convex/agent_tools/sub_agents/instructions/web_instructions.ts
  • services/platform/convex/agent_tools/sub_agents/integration_assistant_tool.ts
  • services/platform/convex/agent_tools/integrations/integration_introspect_tool.ts
  • services/platform/convex/agent_tools/crawler/helpers/types.ts
  • services/platform/convex/agent_tools/integrations/integration_batch_tool.ts
  • services/platform/convex/lib/create_document_agent.ts
  • services/platform/convex/agent_tools/integrations/types.ts
  • services/platform/convex/agent_tools/sub_agents/helpers/format_integrations.ts
  • services/platform/convex/lib/create_web_agent.ts
  • services/platform/convex/agent_tools/sub_agents/document_assistant_tool.ts
  • services/platform/convex/agent_tools/tool_registry.ts
  • services/platform/convex/chat_agent.ts
  • services/platform/convex/model/chat_agent/context_management/context_priority.ts
  • services/platform/convex/lib/create_agent_config.ts
  • services/platform/convex/agent_tools/sub_agents/instructions/document_instructions.ts
  • services/platform/convex/agent_tools/sub_agents/web_assistant_tool.ts
  • services/platform/convex/lib/create_chat_agent.ts
  • services/platform/convex/model/chat_agent/generate_agent_response.ts
  • services/platform/convex/agent_tools/rag/rag_search_tool.ts
  • services/platform/convex/message_metadata.ts
  • services/platform/convex/agent_tools/crawler/helpers/search_and_fetch.ts
  • services/platform/convex/agent_tools/sub_agents/helpers/get_or_create_sub_thread.ts
  • services/platform/convex/agent_tools/sub_agents/helpers/types.ts
  • services/platform/convex/agent_tools/crawler/web_read_tool.ts
  • services/platform/convex/model/chat_agent/on_chat_complete.ts
  • services/platform/convex/agent_tools/integrations/execute_batch_integration_internal.ts
  • services/platform/convex/agent_tools/sub_agents/workflow_assistant_tool.ts
📚 Learning: 2025-12-30T06:21:13.183Z
Learnt from: larryro
Repo: tale-project/tale PR: 37
File: services/platform/convex/model/documents/validators.ts:89-102
Timestamp: 2025-12-30T06:21:13.183Z
Learning: Do not flag a missing trailing newline for TypeScript files in code reviews. POSIX text files should end with a trailing newline and Prettier (or your formatter) will enforce this. Treat the trailing newline as a non-issue in reviews for all TS files.

Applied to files:

  • services/platform/convex/lib/create_integration_agent.ts
  • services/platform/convex/agent_tools/sub_agents/instructions/integration_instructions.ts
  • services/platform/convex/schema.ts
  • services/platform/convex/agent_tools/sub_agents/instructions/web_instructions.ts
  • services/platform/convex/agent_tools/sub_agents/integration_assistant_tool.ts
  • services/platform/convex/agent_tools/integrations/integration_introspect_tool.ts
  • services/platform/convex/agent_tools/crawler/helpers/types.ts
  • services/platform/convex/agent_tools/integrations/integration_batch_tool.ts
  • services/platform/convex/lib/create_document_agent.ts
  • services/platform/convex/agent_tools/integrations/types.ts
  • services/platform/convex/agent_tools/sub_agents/helpers/format_integrations.ts
  • services/platform/convex/lib/create_web_agent.ts
  • services/platform/convex/agent_tools/sub_agents/document_assistant_tool.ts
  • services/platform/convex/agent_tools/tool_registry.ts
  • services/platform/convex/chat_agent.ts
  • services/platform/convex/model/chat_agent/context_management/context_priority.ts
  • services/platform/convex/lib/create_agent_config.ts
  • services/platform/convex/agent_tools/sub_agents/instructions/document_instructions.ts
  • services/platform/convex/agent_tools/sub_agents/web_assistant_tool.ts
  • services/platform/convex/lib/create_chat_agent.ts
  • services/platform/convex/model/chat_agent/generate_agent_response.ts
  • services/platform/convex/agent_tools/rag/rag_search_tool.ts
  • services/platform/convex/message_metadata.ts
  • services/platform/convex/agent_tools/crawler/helpers/search_and_fetch.ts
  • services/platform/convex/agent_tools/sub_agents/helpers/get_or_create_sub_thread.ts
  • services/platform/convex/agent_tools/sub_agents/helpers/types.ts
  • services/platform/convex/agent_tools/crawler/web_read_tool.ts
  • services/platform/convex/model/chat_agent/on_chat_complete.ts
  • services/platform/convex/agent_tools/integrations/execute_batch_integration_internal.ts
  • services/platform/convex/agent_tools/sub_agents/workflow_assistant_tool.ts
📚 Learning: 2025-08-21T15:02:40.745Z
Learnt from: CR
Repo: talecorp/lanserhof PR: 0
File: .cursor/rules/posthog-integration.mdc:0-0
Timestamp: 2025-08-21T15:02:40.745Z
Learning: Applies to **/*.{ts,tsx,js,jsx} : Use a consistent naming convention for feature flag containers; enum/const object members must be UPPERCASE_WITH_UNDERSCORE

Applied to files:

  • services/platform/convex/agent_tools/sub_agents/instructions/integration_instructions.ts
📚 Learning: 2025-11-30T03:53:00.316Z
Learnt from: CR
Repo: tale-project/poc2 PR: 0
File: .cursor/rules/convex_rules.mdc:0-0
Timestamp: 2025-11-30T03:53:00.316Z
Learning: Applies to convex/**/!(model)/*.ts : Exception: Thin wrapper API modules (e.g., `services/platform/convex/documents.ts`) may export multiple Convex functions if they only validate args/returns and delegate to the model layer; must use snake_case for file names and camelCase for function names

Applied to files:

  • services/platform/convex/agent_tools/sub_agents/instructions/integration_instructions.ts
📚 Learning: 2025-12-30T03:05:07.814Z
Learnt from: larryro
Repo: tale-project/tale PR: 36
File: services/platform/convex/agent_tools/database/helpers/schema_definitions.ts:238-242
Timestamp: 2025-12-30T03:05:07.814Z
Learning: In any file under services/platform/convex/agent_tools (e.g., database/helpers/schema_definitions.ts) prefer runtime validation of identifiers like tableName coming from LLM/user input over relying on TypeScript type restrictions alone. Implement validation at call boundaries that returns descriptive, user-friendly errors (e.g., listing available options) instead of returning null or failing at compile time. This approach supports graceful error handling and better UX for misinput.

Applied to files:

  • services/platform/convex/agent_tools/sub_agents/instructions/integration_instructions.ts
  • services/platform/convex/agent_tools/sub_agents/instructions/web_instructions.ts
  • services/platform/convex/agent_tools/sub_agents/integration_assistant_tool.ts
  • services/platform/convex/agent_tools/integrations/integration_introspect_tool.ts
  • services/platform/convex/agent_tools/crawler/helpers/types.ts
  • services/platform/convex/agent_tools/integrations/integration_batch_tool.ts
  • services/platform/convex/agent_tools/integrations/types.ts
  • services/platform/convex/agent_tools/sub_agents/helpers/format_integrations.ts
  • services/platform/convex/agent_tools/sub_agents/document_assistant_tool.ts
  • services/platform/convex/agent_tools/tool_registry.ts
  • services/platform/convex/agent_tools/sub_agents/instructions/document_instructions.ts
  • services/platform/convex/agent_tools/sub_agents/web_assistant_tool.ts
  • services/platform/convex/agent_tools/rag/rag_search_tool.ts
  • services/platform/convex/agent_tools/crawler/helpers/search_and_fetch.ts
  • services/platform/convex/agent_tools/sub_agents/helpers/get_or_create_sub_thread.ts
  • services/platform/convex/agent_tools/sub_agents/helpers/types.ts
  • services/platform/convex/agent_tools/crawler/web_read_tool.ts
  • services/platform/convex/agent_tools/integrations/execute_batch_integration_internal.ts
  • services/platform/convex/agent_tools/sub_agents/workflow_assistant_tool.ts
📚 Learning: 2025-12-20T13:38:13.773Z
Learnt from: larryro
Repo: tale-project/tale PR: 30
File: services/platform/convex/model/chat_agent/chat_with_agent.ts:130-144
Timestamp: 2025-12-20T13:38:13.773Z
Learning: In services/platform/convex/model/chat_agent/chat_with_agent.ts, image fileIds are intentionally displayed as `*(fileId: ${attachment.fileId})*` in the markdown because the AI needs to reference them from thread history for re-analysis using the image tool. This is a business/developer tool, not consumer-facing, so technical metadata visibility is acceptable.

Applied to files:

  • services/platform/convex/agent_tools/sub_agents/integration_assistant_tool.ts
  • services/platform/convex/chat_agent.ts
  • services/platform/convex/agent_tools/sub_agents/instructions/document_instructions.ts
  • services/platform/convex/lib/create_chat_agent.ts
📚 Learning: 2025-07-20T08:40:24.693Z
Learnt from: CR
Repo: talecorp/poc PR: 0
File: .cursor/rules/ai.mdc:0-0
Timestamp: 2025-07-20T08:40:24.693Z
Learning: Applies to **/lib/**/*.ts : For text generation, use the `generateObject` or similar functions from the AI SDK

Applied to files:

  • services/platform/convex/lib/create_document_agent.ts
  • services/platform/convex/agent_tools/sub_agents/instructions/document_instructions.ts
📚 Learning: 2025-07-20T08:40:24.693Z
Learnt from: CR
Repo: talecorp/poc PR: 0
File: .cursor/rules/ai.mdc:0-0
Timestamp: 2025-07-20T08:40:24.693Z
Learning: Applies to **/app/api/**/*.ts : For text generation, use the `generateObject` or similar functions from the AI SDK

Applied to files:

  • services/platform/convex/lib/create_document_agent.ts
  • services/platform/convex/chat_agent.ts
  • services/platform/convex/agent_tools/sub_agents/instructions/document_instructions.ts
  • services/platform/convex/model/chat_agent/generate_agent_response.ts
📚 Learning: 2025-10-03T11:34:20.628Z
Learnt from: CR
Repo: talecorp/poc2 PR: 0
File: .cursor/rules/convex_rules.mdc:0-0
Timestamp: 2025-10-03T11:34:20.628Z
Learning: Applies to convex/**/*.{ts,js} : Always use the new Convex function syntax (query/mutation/action with args/returns/handler)

Applied to files:

  • services/platform/convex/lib/create_web_agent.ts
  • services/platform/convex/chat_agent.ts
📚 Learning: 2026-01-03T04:03:44.197Z
Learnt from: CR
Repo: tale-project/tale PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-01-03T04:03:44.197Z
Learning: Applies to **/*.{ts,tsx} : USE implicit typing whenever possible in TypeScript

Applied to files:

  • services/platform/convex/lib/create_web_agent.ts
📚 Learning: 2025-11-30T12:29:39.745Z
Learnt from: CR
Repo: tale-project/poc2 PR: 0
File: .cursor/rules/workspace_rules.mdc:0-0
Timestamp: 2025-11-30T12:29:39.745Z
Learning: Applies to services/**/convex/*.ts : Thin wrapper API modules in services may export multiple Convex functions as thin wrappers that delegate to model helpers, must use snake_case file names and camelCase export names, and must not contain business logic

Applied to files:

  • services/platform/convex/lib/create_web_agent.ts
📚 Learning: 2025-07-20T08:40:24.693Z
Learnt from: CR
Repo: talecorp/poc PR: 0
File: .cursor/rules/ai.mdc:0-0
Timestamp: 2025-07-20T08:40:24.693Z
Learning: Applies to **/actions/*.ts : For text generation, use the `generateObject` or similar functions from the AI SDK

Applied to files:

  • services/platform/convex/chat_agent.ts
  • services/platform/convex/agent_tools/sub_agents/instructions/document_instructions.ts
  • services/platform/convex/model/chat_agent/generate_agent_response.ts
📚 Learning: 2025-11-30T03:53:00.316Z
Learnt from: CR
Repo: tale-project/poc2 PR: 0
File: .cursor/rules/convex_rules.mdc:0-0
Timestamp: 2025-11-30T03:53:00.316Z
Learning: Applies to convex/**/*.ts : Always use the new Convex function syntax with `query`, `mutation`, `internalQuery`, `internalMutation`, `action`, or `internalAction` with explicit `args`, `returns`, and `handler` properties

Applied to files:

  • services/platform/convex/chat_agent.ts
📚 Learning: 2025-11-30T03:53:00.316Z
Learnt from: CR
Repo: tale-project/poc2 PR: 0
File: .cursor/rules/convex_rules.mdc:0-0
Timestamp: 2025-11-30T03:53:00.316Z
Learning: Applies to convex/**/*.ts : Use the `internal` object from `convex/_generated/api.ts` to call internal functions registered with `internalQuery`, `internalMutation`, or `internalAction`

Applied to files:

  • services/platform/convex/chat_agent.ts
  • services/platform/convex/agent_tools/integrations/execute_batch_integration_internal.ts
📚 Learning: 2025-12-15T14:01:55.275Z
Learnt from: larryro
Repo: tale-project/tale PR: 18
File: services/platform/convex/workflow/actions/conversation/helpers/update_conversations.ts:7-10
Timestamp: 2025-12-15T14:01:55.275Z
Learning: In Convex action helpers (services/platform/convex/workflow/actions/**/helpers/*.ts), using Record<string, unknown> for update parameters is acceptable when field validation is handled at the mutation level in Convex. This provides flexibility for dynamic field updates while keeping validation centralized at the mutation layer.

Applied to files:

  • services/platform/convex/chat_agent.ts
📚 Learning: 2025-07-19T15:30:00.886Z
Learnt from: CR
Repo: talecorp/poc PR: 0
File: .cursor/rules/core-rules.mdc:0-0
Timestamp: 2025-07-19T15:30:00.886Z
Learning: Applies to **/*.{ts,tsx,js,jsx} : Add detailed debug logging at critical points when diagnosing complex bugs or system issues

Applied to files:

  • services/platform/convex/lib/create_agent_config.ts
📚 Learning: 2025-07-19T15:30:00.886Z
Learnt from: CR
Repo: talecorp/poc PR: 0
File: .cursor/rules/core-rules.mdc:0-0
Timestamp: 2025-07-19T15:30:00.886Z
Learning: Applies to **/*.{ts,tsx,js,jsx} : Remove debug logs after optimization is complete

Applied to files:

  • services/platform/convex/lib/create_agent_config.ts
📚 Learning: 2025-07-19T15:30:00.886Z
Learnt from: CR
Repo: talecorp/poc PR: 0
File: .cursor/rules/core-rules.mdc:0-0
Timestamp: 2025-07-19T15:30:00.886Z
Learning: Start every AI Agent task by reviewing language requirements and ensure English-only text is used

Applied to files:

  • services/platform/convex/lib/create_chat_agent.ts
📚 Learning: 2025-08-21T14:59:36.874Z
Learnt from: CR
Repo: talecorp/lanserhof PR: 0
File: .cursorrules:0-0
Timestamp: 2025-08-21T14:59:36.874Z
Learning: Agents must start by checking language requirements, stop if non-English text appears, verify AI SDK usage, and follow existing patterns

Applied to files:

  • services/platform/convex/lib/create_chat_agent.ts
📚 Learning: 2025-10-03T11:34:20.628Z
Learnt from: CR
Repo: talecorp/poc2 PR: 0
File: .cursor/rules/convex_rules.mdc:0-0
Timestamp: 2025-10-03T11:34:20.628Z
Learning: Applies to convex/**/*.{ts,js} : Use withSearchIndex and q.search for full-text search queries

Applied to files:

  • services/platform/convex/agent_tools/crawler/helpers/search_and_fetch.ts
📚 Learning: 2025-07-19T15:30:00.886Z
Learnt from: CR
Repo: talecorp/poc PR: 0
File: .cursor/rules/core-rules.mdc:0-0
Timestamp: 2025-07-19T15:30:00.886Z
Learning: Applies to **/*.{ts,tsx,js,jsx} : Add TypeScript types where missing and create reusable patterns for similar issues

Applied to files:

  • services/platform/convex/agent_tools/sub_agents/helpers/types.ts
🧬 Code graph analysis (15)
services/platform/convex/agent_tools/sub_agents/integration_assistant_tool.ts (3)
services/platform/convex/lib/create_integration_agent.ts (1)
  • createIntegrationAgent (17-42)
services/platform/convex/agent_tools/sub_agents/helpers/format_integrations.ts (1)
  • formatIntegrationsForContext (30-67)
services/platform/convex/agent_tools/sub_agents/helpers/get_or_create_sub_thread.ts (1)
  • getOrCreateSubThread (40-118)
services/platform/convex/agent_tools/integrations/integration_batch_tool.ts (2)
services/platform/convex/agent_tools/types.ts (1)
  • ToolDefinition (19-22)
services/platform/convex/agent_tools/integrations/types.ts (1)
  • BatchOperationResult (132-141)
services/platform/convex/lib/create_document_agent.ts (4)
services/platform/convex/lib/debug_log.ts (1)
  • createDebugLog (27-39)
services/platform/convex/agent_tools/tool_registry.ts (1)
  • ToolName (103-103)
services/platform/convex/lib/create_agent_config.ts (1)
  • createAgentConfig (18-138)
services/platform/convex/agent_tools/sub_agents/instructions/document_instructions.ts (1)
  • DOCUMENT_ASSISTANT_INSTRUCTIONS (8-46)
services/rag/app/services/cognee/cleanup.py (1)
services/rag/app/config.py (2)
  • get_embedding_dimensions (199-230)
  • get_database_url (109-113)
services/platform/convex/agent_tools/sub_agents/document_assistant_tool.ts (3)
services/platform/convex/lib/create_document_agent.ts (1)
  • createDocumentAgent (17-43)
services/platform/convex/agent_tools/sub_agents/helpers/get_or_create_sub_thread.ts (1)
  • getOrCreateSubThread (40-118)
services/platform/convex/agent_tools/types.ts (1)
  • ToolDefinition (19-22)
services/platform/convex/agent_tools/tool_registry.ts (3)
services/platform/convex/agent_tools/integrations/integration_batch_tool.ts (1)
  • integrationBatchTool (40-134)
services/platform/convex/agent_tools/sub_agents/web_assistant_tool.ts (1)
  • webAssistantTool (15-164)
services/platform/convex/agent_tools/sub_agents/document_assistant_tool.ts (1)
  • documentAssistantTool (15-173)
services/platform/convex/lib/create_agent_config.ts (1)
services/platform/convex/lib/debug_log.ts (1)
  • createDebugLog (27-39)
services/rag/app/main.py (1)
services/rag/app/utils.py (1)
  • cleanup_memory (33-43)
services/platform/convex/agent_tools/sub_agents/web_assistant_tool.ts (3)
services/platform/convex/lib/create_web_agent.ts (1)
  • createWebAgent (17-37)
services/platform/convex/agent_tools/sub_agents/helpers/get_or_create_sub_thread.ts (1)
  • getOrCreateSubThread (40-118)
services/platform/convex/agent_tools/types.ts (1)
  • ToolDefinition (19-22)
services/platform/convex/lib/create_chat_agent.ts (1)
services/platform/convex/agent_tools/tool_registry.ts (1)
  • ToolName (103-103)
services/rag/app/services/cognee/service.py (2)
services/rag/app/services/cognee/cleanup.py (2)
  • cleanup_legacy_site_packages_data (173-214)
  • cleanup_missing_local_files_data (217-299)
services/rag/app/config.py (1)
  • get_llm_config (115-197)
services/rag/app/services/cognee/config.py (1)
services/rag/app/config.py (2)
  • get_llm_config (115-197)
  • get_embedding_dimensions (199-230)
services/platform/convex/agent_tools/crawler/helpers/search_and_fetch.ts (5)
services/platform/convex/lib/debug_log.ts (1)
  • createDebugLog (27-39)
services/platform/convex/agent_tools/crawler/helpers/types.ts (3)
  • WebReadSearchAndFetchResult (81-93)
  • FetchedPageContent (72-79)
  • FetchUrlsApiResponse (18-23)
services/platform/convex/agent_tools/crawler/helpers/get_search_service_url.ts (1)
  • getSearchServiceUrl (7-15)
services/platform/convex/agent_tools/crawler/helpers/get_crawler_service_url.ts (1)
  • getCrawlerServiceUrl (7-15)
services/platform/convex/agent_tools/crawler/helpers/fetch_searxng_results.ts (1)
  • fetchSearXNGResults (16-83)
services/platform/convex/agent_tools/sub_agents/helpers/get_or_create_sub_thread.ts (2)
services/platform/convex/agent_tools/sub_agents/helpers/types.ts (2)
  • SubAgentType (6-10)
  • ThreadSummaryWithSubThreads (16-20)
services/platform/convex/_generated/server.d.ts (1)
  • ActionCtx (123-123)
services/platform/convex/agent_tools/sub_agents/workflow_assistant_tool.ts (1)
services/platform/convex/agent_tools/sub_agents/helpers/get_or_create_sub_thread.ts (1)
  • getOrCreateSubThread (40-118)
🪛 Ruff (0.14.10)
services/rag/app/services/cognee/cleanup.py

149-149: Do not catch blind exception: Exception

(BLE001)


168-168: Do not catch blind exception: Exception

(BLE001)

services/rag/app/services/cognee/service.py

424-424: Abstract raise to an inner function

(TRY301)


424-424: Avoid specifying long messages outside the exception class

(TRY003)

services/rag/app/config.py

134-137: Avoid specifying long messages outside the exception class

(TRY003)


142-145: Avoid specifying long messages outside the exception class

(TRY003)


150-153: Avoid specifying long messages outside the exception class

(TRY003)


158-161: Avoid specifying long messages outside the exception class

(TRY003)


216-221: Avoid specifying long messages outside the exception class

(TRY003)


225-225: Abstract raise to an inner function

(TRY301)


225-225: Avoid specifying long messages outside the exception class

(TRY003)


226-226: Consider moving this statement to an else block

(TRY300)


228-230: Avoid specifying long messages outside the exception class

(TRY003)


244-247: Avoid specifying long messages outside the exception class

(TRY003)

Comment thread services/platform/convex/agent_tools/crawler/helpers/types.ts
Comment thread services/rag/app/main.py
Comment thread services/rag/app/main.py
Comment thread services/rag/app/services/cognee/cleanup.py Outdated
Comment thread services/rag/app/services/cognee/cleanup.py
Comment thread services/rag/app/services/cognee/cleanup.py
claude and others added 5 commits January 5, 2026 09:35
Refactor the chat agent to delegate high-context tools to specialized
sub-agents for context isolation. This prevents large outputs (web pages,
documents, database results) from polluting the main agent's context.

New sub-agents:
- web_assistant: Handles web_read (isolates 20K-50K token web pages)
- document_assistant: Handles pdf, image, docx, pptx, generate_excel
- integration_assistant: Handles integration, integration_introspect,
  verify_approval (requires admin/developer role)

Chat agent now uses 8 tools (down from 13):
- Direct tools: customer_read, product_read, rag_search, context_search
- Sub-agents: web_assistant, document_assistant, integration_assistant,
  workflow_assistant

Benefits:
- ~40-50% token savings on tool schema
- Context isolation for large tool outputs
- Better specialization per sub-agent
- Simpler maintenance with isolated tool groups

Files created:
- convex/lib/create_{web,document,integration}_agent.ts
- convex/agent_tools/sub_agents/{web,document,integration}_assistant_tool.ts
- convex/agent_tools/sub_agents/instructions/{web,document,integration}_instructions.ts

Files modified:
- convex/agent_tools/tool_registry.ts
- convex/lib/create_chat_agent.ts
- Add search_and_fetch operation to web_read tool that combines search
  and parallel content fetching in a single call for faster results
- Implement sub-thread reuse across sub-agent calls within the same
  parent thread, enabling context persistence (stored in thread summary)
- Update web_assistant instructions to recommend search_and_fetch
- Change SearXNG port from 8080 to 8003 in docker compose

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add integration_batch tool for parallel multi-operation execution
- Optimize SQL credentials decryption (done once per batch)
- Strip SQL queries from introspection results to reduce token usage
- Lower RAG search default top_k from 10 to 5 for faster responses
- Add subThreadId tracking for sub-agent thread reuse
- Add format_integrations helper for sub-agent context

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Remove all hardcoded defaults for LLM/embedding configuration
- Require explicit OPENAI_API_KEY, OPENAI_BASE_URL, OPENAI_MODEL,
  OPENAI_EMBEDDING_MODEL, and EMBEDDING_DIMENSIONS env vars
- Add get_embedding_dimensions() for configurable vector dimensions
- Replace per-request GC middleware with periodic 60s background task
- Add migrate_vector_dimensions() to auto-drop tables with mismatched
  dimensions when embedding model changes
- Cache LLM config and reuse OpenAI client with connection pooling
- Fix BAML model name to use original without 'openai/' prefix
- Always add 'openai/' prefix for LiteLLM routing on non-OpenAI endpoints

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Role validation only executes when userId is truthy. This fix ensures
userId is required, preventing the role check from being bypassed
when only threadId is provided.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@larryro larryro force-pushed the claude/refactor-chat-agent-subagents-TYYGe branch from a3cff85 to 099dc00 Compare January 5, 2026 01:35
larryro and others added 2 commits January 5, 2026 09:36
When integration_tool is called from integration_assistant sub-agent,
use parentThreadId (if available) for approval card linking instead
of the sub-thread's threadId. This ensures approvals are linked to
the parent thread where the user can see and interact with them.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Added inline comment explaining that success=true indicates the
operation completed (search worked), while partial page fetch failures
are tracked separately in pages_failed and fetched_pages[].success.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
larryro and others added 7 commits January 5, 2026 09:40
Added inline comment explaining why 0.3 is used as the default
similarity_threshold for RAG search. This value balances recall
and precision for embedding-based search with cosine similarity.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Updated document_assistant, web_assistant, workflow_assistant, and
integration_assistant tools to require threadId upfront instead of
using non-null assertions (threadId!) later. This prevents potential
runtime errors when threadId is not provided.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- config.py: Fix exception handling in get_embedding_dimensions() to
  avoid swallowing the inner ValueError message
- main.py: Add exception handling in periodic_gc_cleanup() to prevent
  background task failures from crashing the service
- cleanup.py: Use urlparse instead of manual string splitting for
  robustness and security

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Replace ctx: any with ActionCtx type
- Replace (integration as any) casts with direct property access
- Add SqlOperationConfig type extending OperationConfig
- Use type narrowing with 'in' operator for result property access
- Replace params?: any with params?: Record<string, unknown>

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Access sqlOperations and connector directly from Doc<'integrations'>
since they are properly typed in the schema.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add done callback to monitor the periodic GC cleanup task. If the task
dies unexpectedly (not via cancellation), the failure is logged.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add new `reset` command to completely remove blue-green deployment state
- Shows containers that will be removed with their current status
- Prompts for confirmation (can bypass with --force/-f flag)
- Cleans up state file to allow returning to normal docker compose mode
- Clarify that `cleanup` preserves active deployment while `reset` removes all

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@larryro larryro merged commit 0441e6a into main Jan 5, 2026
2 checks passed
@larryro larryro deleted the claude/refactor-chat-agent-subagents-TYYGe branch January 5, 2026 02:44
larryro pushed a commit that referenced this pull request Jan 5, 2026
…tions

Add typed interfaces and type guards to eliminate `any` casts when
accessing integration-specific fields like sqlConnectionConfig and
sqlOperations.

Changes:
- Add SqlIntegration and RestApiIntegration interfaces to types.ts
- Add isSqlIntegration() and isRestApiIntegration() type guards
- Add getIntegrationType() helper for backward-compatible type access
- Update execute_batch_integration_internal.ts to use type guards
- Update execute_sql_integration.ts to use SqlIntegration type
- Update integration_action.ts to use type guards
- Update integration_introspect_tool.ts to use type guards

This improves type safety and removes widespread `any` usage that was
identified during PR #76 code review.

Closes #79
larryro pushed a commit that referenced this pull request Jan 6, 2026
…tions

Add typed interfaces and type guards to eliminate `any` casts when
accessing integration-specific fields like sqlConnectionConfig and
sqlOperations.

Changes:
- Add SqlIntegration and RestApiIntegration interfaces to types.ts
- Add isSqlIntegration() and isRestApiIntegration() type guards
- Add getIntegrationType() helper for backward-compatible type access
- Update execute_batch_integration_internal.ts to use type guards
- Update execute_sql_integration.ts to use SqlIntegration type
- Update integration_action.ts to use type guards
- Update integration_introspect_tool.ts to use type guards

This improves type safety and removes widespread `any` usage that was
identified during PR #76 code review.

Closes #79
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.

2 participants