fix: stackable draft edits (draft_id) + honest publish with security-check wait#22
Merged
Merged
Conversation
…check wait
Two fixes for the draft workflow:
1. Edit tools spawned a new draft from the live version on every call, so
multi-step changes (prompt + pre-call + tools) could never accumulate.
update_agent_prompt, set_pre_call_api, add_agent_tool and
remove_agent_tool now accept an optional draft_id and PATCH
/drafts/:draftId/config directly — each call stacks a new revision onto
the same draft. add_agent_tool also gains a batch `tools` array so a
full toolset lands in one workflow_tools write (the backend replaces
that array wholesale).
2. publish_draft sent {activate: true}, but the backend always publishes
inactive pending an async security check (AgentVersionService:433) —
the tool then falsely reported "activated". It now publishes, polls
the version's securityCheck (up to ~60s), activates via
PATCH /versions/:id/activate when it passes, and reports the real
state: activated / pending (with activate_version follow-up) / failed
(with reason). New `activate` param (default true) to skip activation.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Two defects in the versioned-agent draft workflow, found while wiring a multi-tool agent via MCP:
update_agent_prompt,set_pre_call_api,add_agent_tool,remove_agent_tool) creates a new draft from the live version on each call. Configuring prompt + pre-call API + N tools produces N+2 divergent drafts, each holding one change — there is no way to build up a single coherent draft.publish_draftfalsely reports activation. It sends{activate: true}, but main-backend always publishes versions inactive pending an async security check (AgentVersionServicepublishes withisActive: falseby design). The flag is ignored, the tool reports "published and activated successfully", andactiveVersionIdnever moves — silently breaking every subsequent edit, which branches from the stale live version.Fix
draft_id(optional) on all four edit tools — when provided, the tool PATCHes/agent/:id/drafts/:draftId/configdirectly, stacking a new revision onto that draft (backend already supports this; the MCP just never targeted an existing draft). Omitted → previous behavior (fresh draft from live).toolsarray onadd_agent_tool— the backend replacessinglePromptConfig.toolswholesale, so sequential single-tool writes to one draft clobber each other. Batch mode lands a full toolset in one write. Single-tool top-level params still work; duplicate names rejected; enum-param validation preserved.publish_draftreports the truth — publishes, polls the version'ssecurityCheck(pending/passed/failed, ~60s max), activates viaPATCH /versions/:id/activateon pass, and reports the real outcome: activated ✓ / still pending (withactivate_versionfollow-up instruction) / failed (with reason). Newactivateparam (defaulttrue) to publish without activating.Param shapes verified against main-backend:
preCallAPISchema(timeout seconds),apiCallSchema(timeout ms,queryParams[{key,value}]),SecurityCheckStatusenum values.Testing
npm run type-check✓,npm run build✓6a2bc236e4ae5f01956e0e03): three sequential edits produced three divergent drafts; three "successful" publishes leftactiveVersionIdunmoved. Post-merge, will re-wire that agent through the new flow (stacked draft → single publish) as the end-to-end check.🤖 Generated with Claude Code