Skip to content

deploy_agent: a peer_tools option to leave out the peer_agents tools - #836

Open
kaihackney-scale wants to merge 1 commit into
mainfrom
kai/deploy-agent-peer-tools-option
Open

kaihackney-scale wants to merge 1 commit into
mainfrom
kai/deploy-agent-peer-tools-option

Conversation

@kaihackney-scale

@kaihackney-scale kaihackney-scale commented Nov 20, 2026 •

Copy link
Copy Markdown
Collaborator

What and why

A deploy_agent step can narrow an agent's own tools with builtin_tools, but every claude-code turn still gets the
SDK's peer_agents MCP tools, which message the task's other agents. Only code could turn them off: the always-on
verifier does it for its judge. An agent that should have no tools at all, such as an LLM user sim, keeps six it
shouldn't have, even in a task with nothing for it to reach.

deploy_agent now takes peer_tools: false, handled like builtin_tools:

  • It's checked against the agent's card before the first request. An agent whose agent-config takes no peer_tools
    fails the deploy instead of keeping the tools.
  • It's sent with the agent's identity and kept on its card.
  • It's sent again on every prompt_agent and always_on turn, so an agent that restarted doesn't get the tools back.
    A peer user sim now gets its builtin_tools and peer_tools again each turn too; until now it got neither after
    deploy.

Leaving peer_tools unset changes nothing.

How it was tested

  • New unit tests in test_deploy_agent_role_delivery.py: false is sent once with the identity and kept on the card;
    unset sends nothing; an agent that can't take it fails before any request; the field round-trips and must be a
    bool. In test_prompt_agent_builtin_tools.py: each turn resends it, and a user sim gets its own tools and peer tools
    each turn. The two resend tests fail without the prompt_agent change.
  • pytest tst/unit/task_step tst/unit/agents: the same failures as on main and no new ones (they need sandbox
    provider modules that aren't installed locally). make lint: passed.
  • End to end: a claude-code agent deployed on a live sandbox with builtin_tools: {"disable": "*"} and
    peer_tools: false, then one prompt_agent turn with an output_format. The CLI's session log shows the model was
    offered only StructuredOutput, and the turn answered through it. With builtin_tools alone, the same agent is
    offered StructuredOutput plus the six mcp__peer_agents__* tools. The sandbox was terminated.

🤖 Generated with Claude Code

RetriggerView in GreptileConfidence Score: 4/5

Restore the saved tool settings for built-in user simulators before merging.

Fix All in CursorFindings

  1. P1 Built-in users regain peer tools ▶
Fix with agent prompt
### Issue 1
src/agent_env/task_step/task_steps/prompt_agent.py:571-575
**Built-in users regain peer tools.** The new resend runs only in `elif is_user_sim`, so it skips users created by `deploy_user_sim_agent`. If that agent restarts between deployment and `prompt_agent`, its saved `peer_tools: false` is never sent again. Claude Code defaults to `True`, so the user simulator gets the peer tools back. `always_on` also skips this resend for its user simulator. Send the saved tool settings independently of the branches that skip model and prompt setup, and cover the built-in user path in a test.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Summary

Adds peer_tools to agent deployment and carries it into later prompt and always-on steps.

  • Tasks can keep an agent from messaging its peer agents.
  • Prompt turns restore a user sim’s saved tool settings.

Reviews (1) · Last reviewed commit: "deploy_agent: a peer_tools option to lea..." · Reviewed by Greptile

A deploy_agent step can already narrow an agent's own tools with builtin_tools, but every claude-code turn still
got the SDK's peer_agents MCP tools, and only code (the always-on verifier's judge) could turn them off. A task now
sets peer_tools: false on the step. It is checked against the agent's agent-config before the first request (an
agent that can't take it fails the deploy), sent with the identity, kept on the card, and sent again on each
prompt_agent and always_on turn like builtin_tools, including to a peer user sim, which until now got neither again.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kaihackney-scale
kaihackney-scale requested a review from a team as a code owner November 20, 2026 02:31
Comment on lines +571 to +575
user_card = user_sim.a2a_card or {}
# Its own tools and peer tools as deploy_agent set them, again, as for the agent above.
user_config = {k: v for k, v in {"output_format": user_output_format, "model": user_model,
"builtin_tools": user_card.get("builtin_tools"),
"peer_tools": user_card.get("peer_tools")}.items() if v is not None}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Built-in users regain peer tools. The new resend runs only in elif is_user_sim, so it skips users created by deploy_user_sim_agent. If that agent restarts between deployment and prompt_agent, its saved peer_tools: false is never sent again. Claude Code defaults to True, so the user simulator gets the peer tools back. always_on also skips this resend for its user simulator. Send the saved tool settings independently of the branches that skip model and prompt setup, and cover the built-in user path in a test.

Knowledge Base Used: Task-step context and execution

Prompt To Fix With AI
This is a comment left during a code review.
Path: src/agent_env/task_step/task_steps/prompt_agent.py
Line: 571-575

Comment:
**Built-in users regain peer tools.** The new resend runs only in `elif is_user_sim`, so it skips users created by `deploy_user_sim_agent`. If that agent restarts between deployment and `prompt_agent`, its saved `peer_tools: false` is never sent again. Claude Code defaults to `True`, so the user simulator gets the peer tools back. `always_on` also skips this resend for its user simulator. Send the saved tool settings independently of the branches that skip model and prompt setup, and cover the built-in user path in a test.

**Knowledge Base Used:** [Task-step context and execution](https://app.greptile.com/-/switch-tenant?tenant=scale-ai&next=%2Fcustom-context%2Fknowledge-base%2Fscaleapi%2Fagentenv-framework%2F-%2Fdocs%2Ftask-step-execution.md)

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Fix in Cursor Fix in Claude Code Fix in Codex

This branch has not been deployed

No deployments
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