fix the issue where sandbox agents couldn't be added as tools#2000
Merged
Conversation
Signed-off-by: Peter Jausovec <peter.jausovec@solo.io>
|
Warning Testing pausedMonthly snapshot limit reached. Update your plan for additional snapshots and to resume testing. |
Contributor
There was a problem hiding this comment.
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 toAgent) 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
matchedAgentignores 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 onlynamespace/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
approved these changes
Jun 12, 2026
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.
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)