Skip to content

Push manages only webhook and client tools; branches never write the main file - #941

Merged
PaulAsjes merged 1 commit into
mainfrom
pma/agents-as-code-parity-fixes
Nov 20, 2026
Merged

PaulAsjes merged 1 commit into
mainfrom
pma/agents-as-code-parity-fixes

Conversation

@PaulAsjes

@PaulAsjes PaulAsjes commented Nov 20, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Cursor Bugbot found four agents-as-code bugs in the SDK ports. They are fixed there, and the same code is in this reference SDK, so this brings the fixes back to keep all eight SDKs behaving the same. agents.push() now creates and updates only webhook and client tools. An MCP or other unmodeled tool stays attached by the id it was loaded with. A branch push or pull whose agents.json entry has no config file of its own is rejected before anything is sent or written.

Details
  • Managed tools. Agent.tools() used to leave out only system tools, so push would create or PATCH an MCP tool with a stripped config. It now returns only webhook and client tools, which is what the spec already said. A tool of another kind goes into tool_ids and workflow nodes under its loaded id (its tools_by_id key, the first in sort order if there are several). With no loaded id, validate() reports invalid_tool at tools.<name>: Tool "<name>" has type "<type>", which push doesn't create or update: load it with its id or attach it with tool_ids. In a loaded workflow nobody has edited, other-kind tool ids are left as they were.
  • Branch file. _record_agent wrote branch["config"], so a branch entry with no config raised KeyError and an empty one wrote to a bogus path (the ports fell back to the main file). The branch check, which runs before any request, now also requires a non-empty string config on the matching branch entry and raises the existing "has no config file" error. The fallback is gone. The branch lookup is also skipped when there's no branch_id, so an entry missing branch_id can't match a main-branch push.
  • Loaded unmanaged tools. from_json turned every tools_by_id match into a tool object, so update(tools=...) dropped a loaded MCP tool. Now only webhook and client matches become objects. Other kinds stay in tool_ids, as pull already leaves them. tools_by_id still holds them, so a workflow node or add_tool() can use the object.
  • Duplicate id. When tool_ids is assembled, an other-kind tool object whose id is already in the list is skipped. Before this, re-adding a loaded MCP tool with add_tool() listed its id twice.
  • The spec change is in the elevenlabs-js counterpart (docs/agents-as-code/agent-spec.md).
  • Same behaviour as the ports' pma/agents-as-code PRs, e.g. Add agents as code: Agent builder, client.Agents.Push/Pull and CLI projects elevenlabs-go#13 and Add agents as code: Agent builder, Agents.PushAsync/PullAsync and AgentProject elevenlabs-dotnet#12. Reference counterpart, with the spec change: Push manages only webhook and client tools; branches never write the main file elevenlabs-js#500.

Testing

  • pytest tests/agent_builder: 62 passed. The 8 new tests (branch entry with no, empty or non-string config; MCP tool without an id; MCP tool kept by id when loaded, from tools.json and in a workflow node; loaded MCP tool kept in tool_ids and attached once after add_tool()) all fail against main's source. With only fix 4 reverted, the add_tool() assertion fails on its own.
  • ruff format, ruff check and mypy src/elevenlabs/agent_builder pass.

🤖 Generated with Claude Code

…main file

Brings the four agents-as-code fixes the six ports carry back to the reference:

- tools() lists only webhook and client tools. A tool of another kind (mcp...)
  stays attached by the id it was loaded with, in tool_ids and workflow nodes;
  without one, validate() reports invalid_tool.
- A branch entry without a non-empty config path is rejected before anything
  is written, and recording a branch never falls back to the main file.
- from_json keeps loaded tools of other kinds in tool_ids, as pull does, so
  update(tools=...) no longer drops them.
- An other-kind tool whose id is already attached is not listed twice.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@cursor

cursor Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

PR Summary

Medium Risk
Changes agent push tool lifecycle and project branch file handling—behavioral fixes that affect how agents sync to the API and how local branch configs are written, but scoped to agents-as-code with new tests.

Overview
Aligns agents-as-code push/pull with the spec: agents.push() now creates and updates only webhook and client tools. MCP and other kinds stay on the agent via tool_ids using the id from load/tools_by_id; new unmanaged tools without a loaded id fail validate() with a clear invalid_tool message, and Agent.tools() lists only push-managed kinds.

Loading and serialization change so from_json promotes only managed tools into the agent’s tool list; unmanaged matches remain in tool_ids while still in tools_by_id for workflows and add_tool(). Assembling config reuses loaded ids for unmanaged tools, avoids duplicate tool_ids when re-adding a loaded MCP tool, and leaves workflow id remapping to managed tools only.

Branch project writes no longer fall back to the main config file: branch push/pull/record requires a branch agents.json entry with a non-empty string config, raising the existing error before any API call or disk write (including missing, empty, or non-string config).

Reviewed by Cursor Bugbot for commit 0ad696d. Bugbot is set up for automated code reviews on this repo. Configure here.

@PaulAsjes
PaulAsjes merged commit 2268b13 into main Nov 20, 2026
6 checks passed
@PaulAsjes
PaulAsjes deleted the pma/agents-as-code-parity-fixes branch November 20, 2026 17:15
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.

2 participants