Skip to content

Commit d7a8d14

Browse files
feat(harness): apply agent description at harness agent init (#633)
* feat(harness): apply agent description at harness agent init Adds a `description` field to HarnessConfig (defaulting to the VeADK default description), maps it to the DESCRIPTION env var, and passes it to the Agent constructed at harness startup. This lets a deployed harness carry a configured agent description (e.g. for A2A discovery) instead of always using the default. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * test(harness): include `description` in HarnessConfig field contract The creation-time field set in test_adds_creation_time_fields must list the new `description` field added to HarnessConfig. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * feat(harness): name the agent after the harness instead of a constant The harness agent was always named `harness_agent`, so every deployed harness produced an identically-named A2A agent card. Derive the agent name from the harness name (HARNESS_NAME / app_name) via `agent_name_from_harness`, normalizing it to a valid ADK identifier (ADK requires a Python identifier and forbids "user"; harness names also allow "-" and may start with a digit, e.g. "oauth-test" -> "oauth_test"). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 94d04c9 commit d7a8d14

4 files changed

Lines changed: 55 additions & 3 deletions

File tree

‎tests/cloud/test_harness_app_contract.py‎

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,11 @@
3434
RunAgentRequest,
3535
)
3636
from veadk.cloud.harness_app.env_mapping import to_runtime_env
37-
from veadk.cloud.harness_app.utils import config_from_env, split_csv
37+
from veadk.cloud.harness_app.utils import (
38+
agent_name_from_harness,
39+
config_from_env,
40+
split_csv,
41+
)
3842
from veadk.consts import DEFAULT_MODEL_AGENT_NAME
3943
from veadk.prompts.agent_default_prompt import DEFAULT_INSTRUCTION
4044

@@ -91,6 +95,7 @@ def test_extends_overrides(self):
9195
def test_adds_creation_time_fields(self):
9296
assert set(_fields(HarnessConfig)) == set(_fields(HarnessOverrides)) | {
9397
"app_name",
98+
"description",
9499
"knowledgebase_type",
95100
"longterm_memory_type",
96101
"shortterm_memory_type",
@@ -232,3 +237,26 @@ def test_empty_string_is_empty_list(self):
232237

233238
def test_drops_blank_segments(self):
234239
assert split_csv("a,, ,b") == ["a", "b"]
240+
241+
242+
class TestAgentNameFromHarness:
243+
"""The agent name (and thus the A2A card name) is derived from the harness
244+
name, normalized to a valid ADK identifier."""
245+
246+
def test_identifier_passes_through(self):
247+
assert agent_name_from_harness("harness_app") == "harness_app"
248+
249+
def test_hyphens_become_underscores(self):
250+
assert agent_name_from_harness("oauth-test") == "oauth_test"
251+
252+
def test_leading_digit_is_prefixed(self):
253+
assert agent_name_from_harness("2048-bot") == "_2048_bot"
254+
255+
def test_reserved_user_is_escaped(self):
256+
assert agent_name_from_harness("user") == "user_"
257+
258+
def test_result_is_always_a_valid_identifier(self):
259+
for raw in ["oauth-test", "2048-bot", "user", "a.b c", ""]:
260+
name = agent_name_from_harness(raw)
261+
assert name.isidentifier(), raw
262+
assert name != "user"

‎veadk/cloud/harness_app/agent.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
Environment variables:
2323
MODEL_NAME Reasoning model name. Default: VeADK default model.
2424
SYSTEM_PROMPT Agent instruction. Default: VeADK default instruction.
25+
DESCRIPTION Agent description (e.g. for A2A discovery). Default: VeADK default description.
2526
TOOLS Comma-separated built-in tool names, e.g. "web_search,link_reader".
2627
SKILLS Comma-separated skill names, e.g. "data-visualization-cloud,...".
2728
RUNTIME Agent runtime backend: "adk" (default) or "codex".

‎veadk/cloud/harness_app/types.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
from pydantic import BaseModel, Field
3131

3232
from veadk.consts import DEFAULT_MODEL_AGENT_NAME
33-
from veadk.prompts.agent_default_prompt import DEFAULT_INSTRUCTION
33+
from veadk.prompts.agent_default_prompt import DEFAULT_DESCRIPTION, DEFAULT_INSTRUCTION
3434

3535

3636
class HarnessOverrides(BaseModel):
@@ -82,6 +82,7 @@ class HarnessConfig(HarnessOverrides):
8282

8383
app_name: str = Field(default="harness_app", alias="name")
8484
system_prompt: str = Field(default=DEFAULT_INSTRUCTION)
85+
description: str = Field(default=DEFAULT_DESCRIPTION)
8586
knowledgebase_type: str = Field(default="")
8687
longterm_memory_type: str = Field(default="")
8788
shortterm_memory_type: str = Field(default="local")

‎veadk/cloud/harness_app/utils.py‎

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727

2828
import io
2929
import os
30+
import re
3031
import shutil
3132
import tempfile
3233
import zipfile
@@ -66,6 +67,7 @@
6667
"HarnessConfig",
6768
"HarnessOverrides",
6869
"split_csv",
70+
"agent_name_from_harness",
6971
"build_skill_toolset",
7072
"SkillLoadError",
7173
"ToolLoadError",
@@ -111,6 +113,7 @@ def _load_builtin_tool(name: str) -> Any:
111113
"tools": "TOOLS",
112114
"skills": "SKILLS",
113115
"system_prompt": "SYSTEM_PROMPT",
116+
"description": "DESCRIPTION",
114117
"runtime": "RUNTIME",
115118
"structured_tool_calls": "STRUCTURED_TOOL_CALLS",
116119
"include_tools_every_turn": "INCLUDE_TOOLS_EVERY_TURN",
@@ -139,6 +142,24 @@ def split_csv(value: str) -> list[str]:
139142
return [item.strip() for item in value.split(",") if item.strip()]
140143

141144

145+
def agent_name_from_harness(harness_name: str) -> str:
146+
"""Derive a valid ADK agent name from the harness name.
147+
148+
The agent name becomes the A2A agent card's ``name``, so it should reflect
149+
the harness rather than a shared constant. ADK requires the agent ``name``
150+
to be a Python identifier (letters, digits, underscores; not starting with a
151+
digit) and forbids ``"user"``, while harness names also allow ``-`` and may
152+
start with a digit. Normalize: map every non-identifier char to ``_`` and
153+
prefix a digit-leading or empty name with ``_``.
154+
155+
``"oauth-test"`` -> ``"oauth_test"``; ``"2048-bot"`` -> ``"_2048_bot"``.
156+
"""
157+
name = re.sub(r"[^0-9A-Za-z_]", "_", harness_name or "")
158+
if not name or name[0].isdigit():
159+
name = f"_{name}"
160+
return f"{name}_" if name == "user" else name
161+
162+
142163
def _download_and_extract_skill(skill: str, dest_dir: Path) -> Path:
143164
"""Download a skill zip from the skill hub and extract it.
144165
@@ -315,9 +336,10 @@ def _assemble_agent(config: HarnessConfig) -> tuple[Agent, ShortTermMemory]:
315336
)
316337

317338
agent = Agent(
318-
name="harness_agent",
339+
name=agent_name_from_harness(config.app_name),
319340
model_name=config.model_name,
320341
instruction=config.system_prompt,
342+
description=config.description,
321343
tools=tools,
322344
runtime=config.runtime,
323345
enable_responses=config.structured_tool_calls,

0 commit comments

Comments
 (0)