Skip to content

fix(channels): an edit names what changes, and a failed post is written down - #6649

Draft
mmabrouk wants to merge 3 commits into
channels/fix-conversation-semanticsfrom
channels/fix-edit-and-delivery
Draft

fix(channels): an edit names what changes, and a failed post is written down#6649
mmabrouk wants to merge 3 commits into
channels/fix-conversation-semanticsfrom
channels/fix-edit-and-delivery

Conversation

@mmabrouk

@mmabrouk mmabrouk commented Sep 8, 2026

Copy link
Copy Markdown
Member

Context

Stacked on #6647. Two robustness defects from the August live QA, F91, F98 and F87 in the ledger.

Changes

  • An edit names what changes. Before, a plain rename nulled a connection's whole data blob, credential reference included, and bricked it for good. A policy-only agent edit reset the default flag and muted the connection. Both edit models now treat an omitted field as unchanged: the service lays the fields the caller sent over the stored row, merging data key by key and flags field by field, before the write. The DTOs say so in their docstrings, and the DB mapping tolerates an absent field.
  • A failed post is written down. A rejected post left the outbox row in CREATED forever, which reads as "not attempted yet" from outside. The worker now writes FAILED with the platform's reason before it re-raises, so retries and logging behave as before and an operator can see the failure.

Tests

  • New: six edit-semantics tests (rename keeps the credential reference and locator, partial data merges, a flags edit touches only the named flag, a policy-only edit keeps the default, a rename keeps references and policy, unknown agent returns none) and one failed-delivery test. Channels unit tier at the top of the stack: 706 pass.
  • Integration tier against the stack's Postgres: 65 pass. The Agenta channel acceptance test passes live.

https://claude.ai/code/session_01HXt8WBUK9MrWKNTYbUKpaT

@vercel

vercel Bot commented Sep 8, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
agenta-documentation Ready Ready Preview Sep 8, 2026 2:18pm UTC

Request Review

@coderabbitai

coderabbitai Bot commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
📝 Summary

Summary by CodeRabbit

  • New Features

    • Channel connection and agent edits now support partial updates, preserving omitted settings and stored values.
    • Agent data can be updated selectively, including references and policy; explicitly clearing policy remains supported.
    • Failed channel event deliveries can be retried using consistent delivery protection.
  • Bug Fixes

    • Prevented partial edits from unintentionally resetting credentials, references, descriptions, flags, policies, or verification settings.
    • Failed deliveries now retain failure details and transition to sent successfully after a successful retry.

Walkthrough

Channel edit DTOs now support partial updates that preserve omitted stored values. The service layers connection and agent edits before persistence. Outbox delivery records failures, retries failed turn-start events, and reuses deterministic delivery keys.

Changes

Channel edit semantics

Layer / File(s) Summary
Partial edit contracts
api/oss/src/core/channels/dtos.py
Connection and agent edit fields are optional. ChannelAgentDataEdit supports partial references and policy updates with validation.
Service edit layering
api/oss/src/core/channels/service.py
The service merges submitted connection and agent fields with stored records before persistence.
Persistence and edit validation
api/oss/src/dbs/postgres/channels/mappings.py, api/oss/tests/pytest/unit/channels/test_channels_edit_semantics.py
Database mappings preserve omitted values. Tests cover partial data, flags, renames, null policy values, and unknown agents.

Outbox delivery retries

Layer / File(s) Summary
Retry and delivery state
api/oss/src/tasks/asyncio/channels/outbox.py
Failed turn-start events can retry. Delivery failures and successes update outbox status. Delivery keys use deterministic UUID5 values.
Delivery retry validation
api/oss/tests/pytest/unit/channels/test_channels_outbox_worker.py
Tests verify failure recording and retry success with the same idempotency token.

Priority: ⬇️ Low — Defer this channel edit and outbox retry change because its supplied scope is limited to preserving partial edits and recording failed deliveries.

Estimated code review effort: 3 (Moderate) | ~30 minutes

Merge Risk: 🟡 Moderate · up to c45f7

Retries can create duplicate Slack messages after an ambiguous failure, and invalid agent edits can fail after request validation. Resolve these issues before merge.

Sequence Diagram(s)

sequenceDiagram
  participant OutboxWorker
  participant ChannelsDAO
  participant ChannelAdapter
  OutboxWorker->>ChannelsDAO: Load CREATED or FAILED event
  OutboxWorker->>ChannelAdapter: Post message with delivery key
  ChannelAdapter-->>OutboxWorker: Return success or error
  OutboxWorker->>ChannelsDAO: Persist FAILED or SENT status
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 27.27% which is insufficient. The required threshold is 60.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 33 functions across 6 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes both primary changes: preserving omitted edit fields and recording failed posts.
Description check ✅ Passed The description directly explains the edit semantics, failed-delivery handling, and related tests.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 2
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch channels/fix-edit-and-delivery

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@mmabrouk

mmabrouk commented Sep 8, 2026

Copy link
Copy Markdown
Member Author

Codex (astra, medium, simplify skill) reviewed this lane. Verdict: "request changes" on the delivery state, three points, all real, all applied in the last commit:

  1. P1: the FAILED write bumped the row's update time, which fed the idempotency token, so a retry could duplicate a post the platform had accepted. The token is now keyed on the row and its content: a retry of the same content reuses it, an edit mints a new one.
  2. P2: a FAILED indicator row was skipped on redelivery as "already sent". FAILED rows are attempted again.
  3. P2: a later success kept the recorded failure status. Success now writes its own status.

Also from the review: the agent edit's data gets its own model with both fields optional, so a policy-only edit is a valid request (the old model required references); an explicit policy: null clears the policy, and a test pins it. Codex confirmed the layering order against credential rotation and the omitted-versus-sent signal through the request parser. Channels unit tier: 708 pass.

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

@mmabrouk I will review the latest changes, including the delivery-state retry behavior and the agent-edit partial-update semantics.

✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

…en down

- A plain rename nulled a connection's whole data blob, credential
  reference included, and bricked it for good (F98). A policy-only agent
  edit reset the default flag and muted the connection (F91). Both edit
  models now treat an omitted field as unchanged: the service lays the
  fields the caller sent over the stored row, merging data key by key
  and flags field by field, before the write.
- A rejected post left the outbox row in CREATED forever, which reads as
  "not attempted yet" from outside (F87). The worker now writes FAILED
  with the platform's reason before it re-raises.

Claude-Session: https://claude.ai/code/session_01HXt8WBUK9MrWKNTYbUKpaT
- The delivery token is keyed on the row and its content, not on the
  row's update time. A retry of the same content after a FAILED write
  reuses the token, so a post the platform accepted but whose reply
  timed out is never duplicated; an edit to new content mints a new one.
- A FAILED indicator row is attempted again on redelivery instead of
  being skipped as "already sent".
- A success after a failure replaces the recorded failure status.
- An agent edit's data has its own model with both fields optional, so a
  policy-only edit is a valid request; an explicit null policy clears it.
- Tests: failed-then-successful retry with a stable token, and the null
  policy clearing case.

Claude-Session: https://claude.ai/code/session_01HXt8WBUK9MrWKNTYbUKpaT
@mmabrouk
mmabrouk force-pushed the channels/fix-conversation-semantics branch from 9b41cba to cc30cdd Compare September 8, 2026 13:24
@mmabrouk
mmabrouk force-pushed the channels/fix-edit-and-delivery branch from c45f7e9 to 60f1363 Compare September 8, 2026 13:24

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (1)
api/oss/src/tasks/asyncio/channels/outbox.py (1)

301-306: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Route outbox state transitions through ChannelsService.

The failure and success branches call self.channels_service.channels_dao.transition_outbox_event directly. This bypasses the required Service -> DAO Interface boundary. Add a ChannelsService transition method and call it from both branches.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Advanced

Run ID: 670e0f50-5468-4302-a1ba-186485ca3dcc

📥 Commits

Reviewing files that changed from the base of the PR and between 9b41cba and c45f7e9.

📒 Files selected for processing (6)
  • api/oss/src/core/channels/dtos.py
  • api/oss/src/core/channels/service.py
  • api/oss/src/dbs/postgres/channels/mappings.py
  • api/oss/src/tasks/asyncio/channels/outbox.py
  • api/oss/tests/pytest/unit/channels/test_channels_edit_semantics.py
  • api/oss/tests/pytest/unit/channels/test_channels_outbox_worker.py

Included review availability: Your plan provides up to 8 included reviews per hour; 5 remain after this review.

Comment thread api/oss/src/core/channels/dtos.py
Comment thread api/oss/src/tasks/asyncio/channels/outbox.py
…odeRabbit)

An omitted references keeps the stored workflow; sending references: null
would wipe the agent's only runnable target and surface as a confusing
downstream ValidationError when the merged data revalidates. Refuse it at
the edit boundary instead, with a clear message. policy: null still clears.

Claude-Session: https://claude.ai/code/session_01HXt8WBUK9MrWKNTYbUKpaT
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