Skip to content

fix the issue where sandbox agents couldn't be added as tools#2000

Merged
EItanya merged 1 commit into
mainfrom
peterj/fixsbagentastool
Jun 12, 2026
Merged

fix the issue where sandbox agents couldn't be added as tools#2000
EItanya merged 1 commit into
mainfrom
peterj/fixsbagentastool

Conversation

@peterj

@peterj peterj commented Jun 11, 2026

Copy link
Copy Markdown
Collaborator

Fixes an issue where we always assumed agents where of Agent kind. The agent in the tool dialog shows the correct type now too. (a lot of changes in the tsx file, but it's mostly formatting)

Screenshot 2026-06-11 at 11 24 01 AM

Signed-off-by: Peter Jausovec <peter.jausovec@solo.io>
Copilot AI review requested due to automatic review settings June 11, 2026 18:42
@chromatic-com

chromatic-com Bot commented Jun 11, 2026

Copy link
Copy Markdown

Warning

Testing paused

Monthly snapshot limit reached. Update your plan for additional snapshots and to resume testing.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes adding sandbox-backed agents as tools by making agent tool references kind-aware end-to-end (UI → tool reference payload → translator resolution), and updates the tool selection UI to display the correct agent kind.

Changes:

  • UI: include agent kind when creating an Agent tool reference and display the kind in the tools dialog.
  • Translator: resolve Agent tools by TypedReference.Kind (defaulting to Agent) and generate the correct A2A URL for sandbox agents via the controller proxy.
  • Tests: add coverage ensuring kind-based resolution, default-kind behavior, self-reference prevention, and sandbox URL routing.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
ui/src/components/create/SelectToolsDialog.tsx Updates agent tool selection/representation in the dialog, including kind display and tool payload kind.
go/core/internal/controller/translator/agent/compiler.go Implements kind-aware agent-tool resolution, kind-qualified cycle/self-reference checks, and sandbox proxy URL generation.
go/core/internal/controller/translator/agent/sandbox_agent_tool_test.go Adds unit tests validating kind-aware agent tool resolution and sandbox routing behavior.
Comments suppressed due to low confidence (3)

ui/src/components/create/SelectToolsDialog.tsx:263

  • Selection logic for agent items matches only by name/namespace, so selecting a SandboxAgent will also mark an Agent with the same namespace/name as selected (and vice-versa). Compare the tool reference kind as well so Agent vs SandboxAgent remain distinct.
  const isItemSelected = (item: ToolsResponse | AgentResponse): boolean => {
    if (isAgentResponse(item)) {
      const agentResp = item as AgentResponse;

      // "item" is an agent but called item to here so as not to confuse

ui/src/components/create/SelectToolsDialog.tsx:897

  • When rendering selected agent tools, the lookup of matchedAgent ignores the tool reference kind. If an Agent and SandboxAgent share the same namespace/name, the UI can show the wrong description/type in the selected list. Match on kind as well (defaulting missing kinds to "Agent").
                      const matchedAgent = isAgentTool(tool)
                        ? availableAgents.find((a) => {
                            const agentName = tool.agent?.name;
                            const agentNamespace = tool.agent?.namespace;

                            // Match by name and namespace (if namespace is specified)
                            if (agentNamespace) {
                              return (
                                a.agent.metadata.namespace === agentNamespace &&
                                a.agent.metadata.name === agentName
                              );
                            }
                            // If no namespace specified, match by name only
                            return a.agent.metadata.name === agentName;
                          })

go/core/internal/controller/translator/agent/compiler.go:180

  • Cycle/recursion errors are now detected using a kind-qualified key (agentStateKey), but the error messages still print only namespace/name, which can be ambiguous when an Agent and SandboxAgent share the same ref. Include the kind-qualified key in these messages for clarity.
	agentRef := utils.GetObjectRef(agent)
	spec := agent.GetAgentSpec()

	if state.isVisited(agentStateKey(agent)) {
		return fmt.Errorf("cycle detected in agent tool chain: %s -> %s", agentRef, agentRef)
	}

	if state.depth > MAX_DEPTH {
		return fmt.Errorf("recursion limit reached in agent tool chain: %s -> %s", agentRef, agentRef)
	}

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

return {
displayName,
description: agentResp.agent.spec.description,
identifier: `agent-${displayName}`,

return [
<div
key={displayName}
Comment on lines +22 to +24
ctx := context.Background()
scheme := schemev1.Scheme
require.NoError(t, v1alpha2.AddToScheme(scheme))
Comment on lines +633 to +649
const agentRef = k8sRefUtils.toRef(
agentResp.agent.metadata
.namespace || "",
agentResp.agent.metadata.name,
);
const toolToRemove =
localSelectedTools.find(
(tool) =>
isAgentTool(tool) &&
(tool.agent?.name ===
agentRef ||
tool.agent?.name ===
agentResp.agent.metadata
.name),
);
if (toolToRemove)
handleRemoveTool(toolToRemove);
@EItanya EItanya merged commit b9aae28 into main Jun 12, 2026
26 checks passed
@EItanya EItanya deleted the peterj/fixsbagentastool branch June 12, 2026 22:58
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.

3 participants