Skip to content

refactor: use savedMessageId directly instead of re-fetching messages#803

Merged
larryro merged 1 commit into
mainfrom
use-saved-message-id-for-metadata
Mar 17, 2026
Merged

refactor: use savedMessageId directly instead of re-fetching messages#803
larryro merged 1 commit into
mainfrom
use-saved-message-id-for-metadata

Conversation

@larryro
Copy link
Copy Markdown
Collaborator

@larryro larryro commented Mar 17, 2026

Summary

  • Capture savedMessageId from the agent SDK's response and pass it through to metadata saving and approval linking, removing the need to listMessages and search after generation
  • Simplify onAgentComplete by accepting messageId directly instead of re-fetching messages to find the right one
  • Increase workflow completion deadline from 60s to 7 minutes

Test plan

  • Verify message metadata is saved correctly after agent responses (check message_metadata table)
  • Verify approval linking works for tool calls requiring approval
  • Verify workflow completion responses work within the new 7-minute deadline
  • Confirm no regressions in streaming and non-streaming response paths

Summary by CodeRabbit

  • Bug Fixes

    • Extended agent generation timeout to reduce operation failures and improve reliability.
  • Refactor

    • Improved message tracking in agent completion workflows.
    • Enhanced approval linking for agent-generated responses.

Capture the first saved message ID from the agent SDK's response and
pass it through to metadata saving and approval linking, eliminating
the need to list and search through messages after generation. Also
increases workflow completion deadline from 60s to 7 minutes.
Copy link
Copy Markdown

@greptile-apps greptile-apps Bot left a comment

Choose a reason for hiding this comment

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

Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 17, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: df0f81ef-71b2-47a5-8780-4b083475e368

📥 Commits

Reviewing files that changed from the base of the PR and between b261ad7 and 6734311.

📒 Files selected for processing (3)
  • services/platform/convex/agent_tools/workflows/internal_mutations.ts
  • services/platform/convex/lib/agent_completion/on_agent_complete.ts
  • services/platform/convex/lib/agent_response/generate_response.ts

📝 Walkthrough

Walkthrough

This PR modifies the agent response completion flow across three files. It increases the deadline timeout for workflow completion responses from 60 to 420 seconds. It refactors message ID handling in the completion handler to accept an optional messageId field instead of deriving it through message list inspection. The response generation module is updated to capture and propagate the first saved message ID through the completion payload, and to use this ID directly when linking approvals rather than querying for the message.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main refactoring objective: replacing re-fetching logic with direct use of savedMessageId, which is the primary change across all three modified files.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch use-saved-message-id-for-metadata
📝 Coding Plan
  • Generate coding plan for human review comments

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

Tip

CodeRabbit can use Trivy to scan for security misconfigurations and secrets in Infrastructure as Code files.

Add a .trivyignore file to your project to customize which findings Trivy reports.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant