Skip to content

fix(frontend): send committed revision reference only on clean agent runs#4904

Merged
ardaerzin merged 1 commit into
big-agentsfrom
fe-feat/playground-commit-revision-runcontext
Jun 28, 2026
Merged

fix(frontend): send committed revision reference only on clean agent runs#4904
ardaerzin merged 1 commit into
big-agentsfrom
fe-feat/playground-commit-revision-runcontext

Conversation

@ardaerzin

Copy link
Copy Markdown
Contributor

Context

Follow-up to the run-context plumbing in #4892, per Mahmoud's coordination note on direct-call tools: when a variant is committed, the playground should send the committed revision reference with the run request (not just the inline config) so the service can mark the run non-draft and let a self-targeting tool bind its own revision/variant via runContext.

Problem

The canonical playground run builder (buildAgentRequest, used by AgentChatPanel) forwarded the full reference family — application + application_variant + application_revision — on every run whenever the entity carried a UUID, ignoring whether the left-panel config had unsaved edits.

The agent service derives draft-ness purely from a resolved committed-revision reference (services/oss/src/agent/tracing.py_run_context_workflow: is_draft = revision is None), and the SDK resolver (/applications/revisions/retrieve with resolve: True) re-resolves a bare variant ref to its latest revision. So a dirty (edited) run still got marked non-draft, and a self-targeting tool would bind a revision whose config differs from what is actually running.

What changed

web/packages/agenta-playground/src/state/execution/agentRequest.ts — forward the reference family only when the run targets a committed, unmodified revision:

const isCommittedRevisionRun =
    !isDirty && typeof fullReferences?.application_revision?.id === "string"
const references = isCommittedRevisionRun ? fullReferences : null
  • Clean committed revision → full references → service marks the run non-draft; a self-targeting tool binds the exact revision/variant.
  • Dirty (unsaved edits) or uncommitted local draftreferences: null — the service's documented "unsaved inline config carries no revision reference, so is_draft is True" case.
  • application_id URL query is derived independently from the full identity, so a draft run stays associated with its app.

Tests

web/packages/agenta-playground/tests/unit/agentRequest.test.ts — added clean→refs, dirty→null, and uncommitted-local-draft→null coverage (replacing the old partial-ref local-draft case). 24 tests pass, tsc --noEmit clean, source lint clean.

Note / coordination item

Dropping all references for draft runs assumes draft-run traces still surface via application_id/OTel rather than body references. Expressing "draft run bound to a variant" (variant bound but still draft) would need a backend change — an explicit is_draft flag, or not auto-resolving variant → latest revision. This PR is the FE half and is forward-compatible either way.

…ent run request

The agent playground forwarded the full reference family (app + variant +
revision) on every run whenever the entity had a UUID, regardless of whether
the left-panel config had unsaved edits. The agent service derives draft-ness
purely from a resolved committed-revision reference
(services/oss/src/agent/tracing.py `_run_context_workflow`:
`is_draft = revision is None`), and the SDK resolver re-resolves a bare variant
ref to its latest revision, so an edited run still got marked non-draft and a
self-targeting tool would bind a revision whose config differs from what is
actually running.

Forward the reference family only when running a committed, unmodified
revision (`!isDirty` and a real committed revision id is present); otherwise
send `references: null` — the service's documented "unsaved inline config
carries no revision reference, so is_draft is True" case. App scoping rides the
`application_id` URL query independently, so a draft run stays associated with
its app.
@dosubot dosubot Bot added the size:S This PR changes 10-29 lines, ignoring generated files. label Jun 28, 2026
@vercel

vercel Bot commented Jun 28, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
agenta-documentation Ready Ready Preview, Comment Jun 28, 2026 11:55am

Request Review

@dosubot dosubot Bot added the Frontend label Jun 28, 2026
@coderabbitai

coderabbitai Bot commented Jun 28, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: a40f4b97-97b6-484b-8fa1-cd218e248eeb

📥 Commits

Reviewing files that changed from the base of the PR and between 27228f1 and 8bf2c8c.

📒 Files selected for processing (2)
  • web/packages/agenta-playground/src/state/execution/agentRequest.ts
  • web/packages/agenta-playground/tests/unit/agentRequest.test.ts

📝 Walkthrough

Summary by CodeRabbit

  • Bug Fixes
    • Improved request handling so run references are only sent when the run is clean and tied to a committed revision.
    • Kept application scoping in the request URL even when references are omitted for drafts or dirty runs.
    • Updated coverage to verify references are included for committed runs and excluded for dirty or uncommitted drafts.

Walkthrough

buildAgentRequest now conditionally sets references to null when isDirty is true or when no committed application_revision.id exists, using a new fullReferences intermediate. The application_id URL parameter is sourced from fullReferences instead of the gated references. Tests are updated to mock isDirty and cover clean, dirty, and uncommitted draft scenarios.

Conditional references and isDirty gating

Layer / File(s) Summary
Conditional references and URL app scoping
src/state/execution/agentRequest.ts
fullReferences is built unconditionally from the entity; references is set to fullReferences only when isDirty is false and a committed application_revision.id exists, otherwise null. application_id in the URL query is sourced from fullReferences to preserve app scoping in all cases.
Test mock, seed, and scenario coverage
tests/unit/agentRequest.test.ts
isDirty selector added to the workflowMolecule.selectors mock; seed helper extended to accept and set isDirty (default false). Tests replaced/added for clean committed (references present), dirty committed, and uncommitted local draft (both expect references: null with application_id still in the URL).

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly captures the main change: gating committed revision references on clean agent runs.
Description check ✅ Passed The description accurately explains the request-body reference gating and added test coverage.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fe-feat/playground-commit-revision-runcontext

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.

@ardaerzin

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jun 28, 2026

Copy link
Copy Markdown
✅ 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.

@ardaerzin ardaerzin merged commit 4b76464 into big-agents Jun 28, 2026
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Frontend size:S This PR changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant