fix(frontend): send committed revision reference only on clean agent runs#4904
Conversation
…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.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughSummary by CodeRabbit
Walkthrough
Conditional references and isDirty gating
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
|
@coderabbitai review |
✅ Action performedReview finished.
|
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 byAgentChatPanel) 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/retrievewithresolve: 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:references: null— the service's documented "unsaved inline config carries no revision reference, sois_draftis True" case.application_idURL 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 --noEmitclean, 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 explicitis_draftflag, or not auto-resolving variant → latest revision. This PR is the FE half and is forward-compatible either way.