fix: copilot by using bucketId and adjust agent models#1691
fix: copilot by using bucketId and adjust agent models#1691joanagmaia wants to merge 9 commits intomainfrom
Conversation
Signed-off-by: Joana Maia <jmaia@contractor.linuxfoundation.org>
Signed-off-by: Joana Maia <jmaia@contractor.linuxfoundation.org>
There was a problem hiding this comment.
Pull request overview
This PR updates the AWS Bedrock model identifier from Claude Sonnet 4 (us.anthropic.claude-sonnet-4-20250514-v1:0) to Claude Opus 4-6 (us.anthropic.claude-opus-4-6-v1) across all usage locations in the chat/data copilot system. This represents both a model upgrade (from Sonnet to Opus) and a change in the model identifier format.
Changes:
- Updated Bedrock model identifier from Sonnet 4 to Opus 4-6 across all code and test files
- Updated documentation to reflect the new model configuration
- Maintained consistency across production code, tests, and documentation
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| frontend/lib/chat/data-copilot.ts | Updated BEDROCK_MODEL_ID constant in main DataCopilot class |
| frontend/lib/chat/chart/generator.ts | Updated model identifier for chart generation functionality |
| frontend/lib/chat/tests/router.test.ts | Updated model identifier in router agent tests |
| frontend/lib/chat/tests/auditor.test.ts | Updated model identifier in auditor agent tests |
| frontend/lib/chat/Readme.md | Updated documentation to reflect new model configuration |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Signed-off-by: Joana Maia <jmaia@contractor.linuxfoundation.org>
Signed-off-by: Joana Maia <jmaia@contractor.linuxfoundation.org>
Signed-off-by: Joana Maia <jmaia@contractor.linuxfoundation.org>
Signed-off-by: Joana Maia <jmaia@contractor.linuxfoundation.org>
Signed-off-by: Joana Maia <jmaia@contractor.linuxfoundation.org>
Signed-off-by: Joana Maia <jmaia@contractor.linuxfoundation.org>
|
@epipav can you check it out and let me know what you think? — Summary of the changes in the PR description. The copilot was quite broken in production, so I made a set of changes to address the main issues. The primary problem was that I also evaluated using Opus 4.6 across all agents, but it proved too slow—particularly for the Router and Pipe agents, where it would often stall or take too long to respond. Given the current architecture, it doesn’t seem viable to use it there without more significant changes, so I’m now using one model for some agents, and opus model for others. Additionally, I improved the data summary returned to the user by including the top 3 rows. This increases token usage slightly, but the improvement in response clarity and UX is noticeable. While this won’t cover every edge case, it works well for common queries like “most active X” and similar straightforward requests. Let me know if anything here doesn’t look right—especially since you have more context on some parts of the system. |
There was a problem hiding this comment.
Looks good overall - have u tried using Sonnet 4.6?
epipav
left a comment
There was a problem hiding this comment.
Thanks for fixing the bucket issue! Added nitpicks and few readablity comments
| // For now, we use the Opus model for text-to-SQL and auditor. | ||
| // The model is currently too slow for both the pipe and router agents. |
There was a problem hiding this comment.
readability NIT: This comment block should come before let model: string | undefined = this.BEDROCK_SONNET_MODEL_ID
|
|
||
| /** Amazon Bedrock language model instance */ | ||
| private model: LanguageModelV1; | ||
| /** Amazon Bedrock language model instance for routing and auditing (Sonnet) */ |
There was a problem hiding this comment.
Auditor uses Opus, not Sonnet
| /** Amazon Bedrock language model instance for routing and auditing (Sonnet) */ | ||
| private sonnetModel: LanguageModelV1; | ||
|
|
||
| /** Amazon Bedrock language model instance for text-to-SQL, pipe, and chart agents (Opus) */ |
There was a problem hiding this comment.
docs look wrong: pipe agent uses Sonnet, not Opus
| * Generate statistical summary of dataset | ||
| * Token-efficient: ~400-500 tokens for typical dataset | ||
| * No raw data samples sent to LLM - only statistics | ||
| * Token-efficient: ~1500-200 tokens for typical dataset |
There was a problem hiding this comment.
There's a typo here, should be 1500-2000
| try { | ||
| const result = await executeTinybirdPipe(pipeInstruction.name, pipeInstruction.inputs); | ||
| const inputs = | ||
| bucketId !== null ? { bucketId, ...pipeInstruction.inputs } : pipeInstruction.inputs; |
There was a problem hiding this comment.
The optional bucketId param can also be undefined here when the function call doesn't have bucketId. Checking with loose equality (bucketId != null) also catches undefined here
| { headers: { Authorization: `Bearer ${tinybirdToken}` }, timeout: 10_000 }, | ||
| ); | ||
| this.bucketId = response.data?.[0]?.bucketId ?? null; | ||
| console.warn(`🪣 [DataCopilot] bucketId for "${project}": ${this.bucketId}`); |
There was a problem hiding this comment.
NIT: let's use console.log here, since it's a non-warning log
| // Ideally the entire response would be available to the auditor. But that would be too costly. | ||
| // TODO: Explore a better way to have a proper summary of the data that answers the user's question directly. |
There was a problem hiding this comment.
NIT: This TODO comment doesn't add much here - Data summary already tries to tackle this somewhat, and if it needs better summarization, I think we can create a task for it
| const allTools = await this.mcpClient.tools({}); | ||
|
|
||
| // Filter out tools with empty descriptions — Bedrock rejects them with a validation error | ||
| this.tbTools = Object.fromEntries( |
There was a problem hiding this comment.
Anything important is missing descriptions? Should we report these to Tinybird support?



This pull request introduces significant improvements to the Data Copilot's agent orchestration and data auditing, focusing on model selection, Tinybird integration, and auditor prompt accuracy. The changes enable more precise use of language models for different agents, ensure correct data partitioning with Tinybird's
bucketId, and enhance the auditor's ability to provide user-relevant summaries by including actual data samples.Model selection and agent orchestration:
DataCopilotclass to use two separate Bedrock models: Sonnet for routing and pipe agents, and Opus for text-to-SQL and auditor agents, allowing for more optimal model usage per agent type.Tinybird integration and data partitioning:
bucketIdper project, injecting it into all relevant Tinybird pipe calls and tool executions to ensure correct data partitioning and prevent cross-project data leakage.Auditor prompt and data summary improvements:
feedback_to_routerandsummaryto be nullable, reflecting cases where these may not be present.Other improvements:
previousFeedbackis set toundefinedif not present, improving retry logic robustness.These changes collectively improve the reliability, accuracy, and user-friendliness of the Data Copilot's responses and its integration with the Tinybird data backend.