Skip to content

Commit 74cf718

Browse files
committed
reverse requirements of agent card v. agent server
Signed-off-by: Fabian Gonzalez <fabian.gonzalez@solo.io>
1 parent d9a9286 commit 74cf718

8 files changed

Lines changed: 55 additions & 61 deletions

File tree

go/api/v1alpha2/agent_types.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -106,13 +106,13 @@ type ByoDeploymentSpec struct {
106106
}
107107

108108
type RemoteAgentSpec struct {
109-
// URL is the URL the agent is served at.
110-
// +kubebuilder:validation:MinLength=1
111-
URL string `json:"url,omitempty"`
112109
// AgentCardURL is the URL of the agent card JSON file.
113-
// If not specified, the default value is {url}/.well-known/agent.json.
114-
// +optional
110+
// +kubebuilder:validation:MinLength=1
115111
AgentCardURL string `json:"agentCardUrl,omitempty"`
112+
// ServerURL is the URL of the agent server.
113+
// If not specified, the default value is fetched from the agent card.
114+
// +optional
115+
ServerURL string `json:"serverUrl,omitempty"`
116116
}
117117

118118
type SharedDeploymentSpec struct {

go/config/crd/bases/kagent.dev_agents.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6429,14 +6429,14 @@ spec:
64296429
remote:
64306430
properties:
64316431
agentCardUrl:
6432-
description: |-
6433-
AgentCardURL is the URL of the agent card JSON file.
6434-
If not specified, the default value is {url}/.well-known/agent.json.
6435-
type: string
6436-
url:
6437-
description: URL is the URL the agent is served at.
6432+
description: AgentCardURL is the URL of the agent card JSON file.
64386433
minLength: 1
64396434
type: string
6435+
serverUrl:
6436+
description: |-
6437+
ServerURL is the URL of the agent server.
6438+
If not specified, the default value is fetched from the agent card.
6439+
type: string
64406440
type: object
64416441
type:
64426442
allOf:

go/internal/controller/translator/adk_api_translator.go

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -144,15 +144,8 @@ func (a *adkApiTranslator) TranslateAgent(
144144
}
145145
return a.buildManifest(ctx, agent, dep, nil, agentCard)
146146
case v1alpha2.AgentType_Remote:
147-
var agentCardURL string
148-
if agent.Spec.Remote.AgentCardURL != "" {
149-
agentCardURL = agent.Spec.Remote.AgentCardURL
150-
} else {
151-
agentCardURL = fmt.Sprintf("%s/.well-known/agent.json", agent.Spec.Remote.URL)
152-
}
153-
154-
// fetch the agent card from the URL
155-
agentCard, remoteConfig, err := a.fetchRemoteAgentDetails(agent.Spec.Remote.URL, agentCardURL)
147+
// fetch the agent card details from the URL
148+
agentCard, remoteConfig, err := a.fetchRemoteAgentDetails(agent.Spec.Remote)
156149
if err != nil {
157150
return nil, err
158151
}
@@ -168,11 +161,10 @@ func (a *adkApiTranslator) TranslateAgent(
168161
}
169162
}
170163

171-
// TODO: Move away from this (no need to store information in the database) after resolving issue with not seeing the agent response in chat.
172-
func (a *adkApiTranslator) fetchRemoteAgentDetails(serverURL, agentCardURL string) (*server.AgentCard, *adk.RemoteAgentConfig, error) {
164+
func (a *adkApiTranslator) fetchRemoteAgentDetails(r *v1alpha2.RemoteAgentSpec) (*server.AgentCard, *adk.RemoteAgentConfig, error) {
173165
agentCard := &server.AgentCard{}
174166

175-
resp, err := http.Get(agentCardURL)
167+
resp, err := http.Get(r.AgentCardURL)
176168
if err != nil {
177169
return nil, nil, err
178170
}
@@ -188,12 +180,14 @@ func (a *adkApiTranslator) fetchRemoteAgentDetails(serverURL, agentCardURL strin
188180
return nil, nil, err
189181
}
190182

191-
// modify the agent card url to be the provided server url for communication
192-
agentCard.URL = serverURL
183+
// override the agent card's server url to be the provided server url if provided
184+
if r.ServerURL != "" {
185+
agentCard.URL = r.ServerURL
186+
}
193187

194188
agentConfig := &adk.RemoteAgentConfig{
195189
Name: agentCard.Name,
196-
Url: serverURL,
190+
Url: agentCard.URL,
197191
Description: agentCard.Description,
198192
}
199193

helm/kagent-crds/templates/kagent.dev_agents.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6429,14 +6429,14 @@ spec:
64296429
remote:
64306430
properties:
64316431
agentCardUrl:
6432-
description: |-
6433-
AgentCardURL is the URL of the agent card JSON file.
6434-
If not specified, the default value is {url}/.well-known/agent.json.
6435-
type: string
6436-
url:
6437-
description: URL is the URL the agent is served at.
6432+
description: AgentCardURL is the URL of the agent card JSON file.
64386433
minLength: 1
64396434
type: string
6435+
serverUrl:
6436+
description: |-
6437+
ServerURL is the URL of the agent server.
6438+
If not specified, the default value is fetched from the agent card.
6439+
type: string
64406440
type: object
64416441
type:
64426442
allOf:

ui/src/app/actions/agents.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,8 @@ function fromAgentFormDataToAgent(agentFormData: AgentFormData): Agent {
140140
};
141141
} else if (type === "Remote") {
142142
base.spec!.remote = {
143-
url: agentFormData.remoteUrl || "",
144-
agentCardUrl: agentFormData.remoteAgentCardUrl || undefined,
143+
agentCardUrl: agentFormData.remoteAgentCardUrl || "",
144+
serverUrl: agentFormData.remoteServerUrl || undefined,
145145
} as any;
146146
}
147147

ui/src/app/agents/new/page.tsx

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ interface ValidationErrors {
3434
knowledgeSources?: string;
3535
tools?: string;
3636
memory?: string;
37-
remoteUrl?: string;
37+
remoteAgentCardUrl?: string;
3838
}
3939

4040
interface AgentPageContentProps {
@@ -77,8 +77,8 @@ function AgentPageContent({ isEditMode, agentName, agentNamespace }: AgentPageCo
7777
byoCmd: string;
7878
byoArgs: string;
7979
// Remote
80-
remoteUrl: string;
8180
remoteAgentCardUrl: string;
81+
remoteServerUrl: string;
8282
replicas: string;
8383
imagePullPolicy: string;
8484
imagePullSecrets: string[];
@@ -101,8 +101,8 @@ function AgentPageContent({ isEditMode, agentName, agentNamespace }: AgentPageCo
101101
byoImage: "",
102102
byoCmd: "",
103103
byoArgs: "",
104-
remoteUrl: "",
105104
remoteAgentCardUrl: "",
105+
remoteServerUrl: "",
106106
replicas: "",
107107
imagePullPolicy: "",
108108
imagePullSecrets: [""],
@@ -146,8 +146,8 @@ function AgentPageContent({ isEditMode, agentName, agentNamespace }: AgentPageCo
146146
byoImage: "",
147147
byoCmd: "",
148148
byoArgs: "",
149-
remoteUrl: "",
150149
remoteAgentCardUrl: "",
150+
remoteServerUrl: "",
151151
}));
152152
} else if (agent.spec.type === "BYO") {
153153
setState(prev => ({
@@ -167,8 +167,8 @@ function AgentPageContent({ isEditMode, agentName, agentNamespace }: AgentPageCo
167167
? { name: e.name || "", isSecret: true, secretName: e.valueFrom.secretKeyRef.name || "", secretKey: e.valueFrom.secretKeyRef.key || "", optional: e.valueFrom.secretKeyRef.optional }
168168
: { name: e.name || "", value: e.value || "", isSecret: false }
169169
)).concat((agent.spec?.byo?.deployment?.env || []).length === 0 ? [{ name: "", value: "", isSecret: false }] : []),
170-
remoteUrl: "",
171170
remoteAgentCardUrl: "",
171+
remoteServerUrl: "",
172172
}));
173173
} else if (agent.spec.type === "Remote") {
174174
setState(prev => ({
@@ -184,8 +184,8 @@ function AgentPageContent({ isEditMode, agentName, agentNamespace }: AgentPageCo
184184
imagePullPolicy: "",
185185
imagePullSecrets: [""],
186186
envPairs: [{ name: "", value: "", isSecret: false }],
187-
remoteUrl: agent.spec?.remote?.url || "",
188187
remoteAgentCardUrl: agent.spec?.remote?.agentCardUrl || "",
188+
remoteServerUrl: agent.spec?.remote?.serverUrl || "",
189189
}));
190190
}
191191

@@ -235,7 +235,7 @@ function AgentPageContent({ isEditMode, agentName, agentNamespace }: AgentPageCo
235235
modelName: state.selectedModel?.ref || "",
236236
tools: state.selectedTools,
237237
byoImage: state.byoImage,
238-
remoteUrl: state.remoteUrl,
238+
remoteAgentCardUrl: state.remoteAgentCardUrl,
239239
};
240240

241241
const newErrors = validateAgentData(formData);
@@ -258,7 +258,7 @@ function AgentPageContent({ isEditMode, agentName, agentNamespace }: AgentPageCo
258258
case 'model': formData.modelName = value; break;
259259
case 'tools': formData.tools = value; break;
260260
case 'memory': formData.memory = value; break;
261-
case 'remoteUrl': (formData as any).remoteUrl = value; break;
261+
case 'remoteAgentCardUrl': (formData as any).remoteAgentCardUrl = value; break;
262262
}
263263

264264
const fieldErrors = validateAgentData(formData);
@@ -325,8 +325,8 @@ function AgentPageContent({ isEditMode, agentName, agentNamespace }: AgentPageCo
325325
})
326326
.filter((e): e is EnvVar => e !== null),
327327
// Remote
328-
remoteUrl: state.remoteUrl || undefined,
329-
remoteAgentCardUrl: state.remoteAgentCardUrl || undefined,
328+
remoteAgentCardUrl: state.remoteAgentCardUrl || "",
329+
remoteServerUrl: state.remoteServerUrl || undefined,
330330
};
331331

332332
let result;
@@ -617,25 +617,25 @@ function AgentPageContent({ isEditMode, agentName, agentNamespace }: AgentPageCo
617617
{state.agentType === "Remote" && (
618618
<div className="space-y-4">
619619
<div>
620-
<Label className="text-sm mb-2 block">Remote Agent URL</Label>
620+
<Label className="text-sm mb-2 block">Agent Card URL</Label>
621621
<Input
622-
value={state.remoteUrl}
623-
onChange={(e) => setState(prev => ({ ...prev, remoteUrl: e.target.value }))}
624-
onBlur={() => validateField('remoteUrl', state.remoteUrl)}
625-
placeholder="https://remote-agent.example.com"
622+
value={state.remoteAgentCardUrl}
623+
onChange={(e) => setState(prev => ({ ...prev, remoteAgentCardUrl: e.target.value }))}
624+
onBlur={() => validateField('remoteAgentCardUrl', state.remoteAgentCardUrl)}
625+
placeholder={`https://remote-agent.example.com/.well-known/agent.json`}
626626
disabled={state.isSubmitting || state.isLoading}
627627
/>
628-
{state.errors && state.errors.remoteUrl && <p className="text-red-500 text-sm mt-1">{state.errors.remoteUrl}</p>}
628+
{state.errors.remoteAgentCardUrl && <p className="text-red-500 text-sm mt-1">{state.errors.remoteAgentCardUrl}</p>}
629629
</div>
630630
<div>
631-
<Label className="text-sm mb-2 block">Agent Card URL (optional)</Label>
631+
<Label className="text-sm mb-2 block">Agent Server URL</Label>
632632
<p className="text-xs mb-2 block text-muted-foreground">
633-
If not provided, the agent card will be automatically discovered using the remote agent URL.
633+
The URL of the agent server to use for the remote agent. If not provided, the agent card will be used to discover the agent server URL.
634634
</p>
635635
<Input
636-
value={state.remoteAgentCardUrl}
637-
onChange={(e) => setState(prev => ({ ...prev, remoteAgentCardUrl: e.target.value }))}
638-
placeholder={`${state.remoteUrl}/.well-known/agent.json`}
636+
value={state.remoteServerUrl}
637+
onChange={(e) => setState(prev => ({ ...prev, remoteServerUrl: e.target.value }))}
638+
placeholder="https://remote-agent.example.com"
639639
disabled={state.isSubmitting || state.isLoading}
640640
/>
641641
</div>

ui/src/components/AgentsProvider.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ interface ValidationErrors {
1717
knowledgeSources?: string;
1818
tools?: string;
1919
memory?: string;
20-
remoteUrl?: string;
20+
remoteAgentCardUrl?: string;
2121
}
2222

2323
export interface AgentFormData {
@@ -34,8 +34,8 @@ export interface AgentFormData {
3434
byoCmd?: string;
3535
byoArgs?: string[];
3636
// Remote fields
37-
remoteUrl?: string;
3837
remoteAgentCardUrl?: string;
38+
remoteServerUrl?: string;
3939
// Shared deployment optional fields
4040
replicas?: number;
4141
imagePullSecrets?: Array<{ name: string }>;
@@ -168,8 +168,8 @@ export function AgentsProvider({ children }: AgentsProviderProps) {
168168
errors.model = "Container image is required";
169169
}
170170
} else if (type === "Remote") {
171-
if (!data.remoteUrl || data.remoteUrl.trim() === "") {
172-
errors.remoteUrl = "Remote agent URL is required";
171+
if (!data.remoteAgentCardUrl || data.remoteAgentCardUrl.trim() === "") {
172+
errors.remoteAgentCardUrl = "Agent card URL is required";
173173
}
174174
}
175175

ui/src/types/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -264,8 +264,8 @@ export interface BYOAgentSpec {
264264
}
265265

266266
export interface RemoteAgentSpec {
267-
url: string;
268-
agentCardUrl?: string;
267+
agentCardUrl: string;
268+
serverUrl?: string;
269269
}
270270

271271
export interface BYODeploymentSpec {

0 commit comments

Comments
 (0)