Skip to content

Commit 47ffacc

Browse files
tongyu0924ekzhu
andauthored
AssistantAgent.metadata for user/application identity information associated with the agent. #6048 (#6057)
This PR introduces a metadata field in AssistantAgentConfig, allowing applications to assign and track identity information for agents. The metadata field is a Dict[str, str] and is included in the configuration for proper serialization. --------- Co-authored-by: Eric Zhu <[email protected]>
1 parent fc2c997 commit 47ffacc

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

docs/dotnet/core/toc.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@
77
- name: Differences from Python
88
href: differences-from-python.md
99
- name: Protobuf message types
10-
href: protobuf-message-types.md
10+
href: protobuf-message-types.md

docs/dotnet/docfx.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,4 +73,4 @@
7373
"keepFileLink": false,
7474
"disableGitFeatures": false
7575
}
76-
}
76+
}

python/packages/autogen-agentchat/src/autogen_agentchat/agents/_assistant_agent.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ class AssistantAgentConfig(BaseModel):
7373
model_client_stream: bool = False
7474
reflect_on_tool_use: bool
7575
tool_call_summary_format: str
76+
metadata: Dict[str, str] | None = None
7677

7778

7879
class AssistantAgent(BaseChatAgent, Component[AssistantAgentConfig]):
@@ -169,6 +170,7 @@ class AssistantAgent(BaseChatAgent, Component[AssistantAgentConfig]):
169170
Available variables: `{tool_name}`, `{arguments}`, `{result}`.
170171
For example, `"{tool_name}: {result}"` will create a summary like `"tool_name: result"`.
171172
memory (Sequence[Memory] | None, optional): The memory store to use for the agent. Defaults to `None`.
173+
metadata (Dict[str, str] | None, optional): Optional metadata for tracking.
172174
173175
Raises:
174176
ValueError: If tool names are not unique.
@@ -613,8 +615,10 @@ def __init__(
613615
reflect_on_tool_use: bool = False,
614616
tool_call_summary_format: str = "{result}",
615617
memory: Sequence[Memory] | None = None,
618+
metadata: Dict[str, str] | None = None,
616619
):
617620
super().__init__(name=name, description=description)
621+
self._metadata = metadata or {}
618622
if reflect_on_tool_use and ModelFamily.is_claude(model_client.model_info["family"]):
619623
warnings.warn(
620624
"Claude models may not work with reflection on tool use because Claude requires that any requests including a previous tool use or tool result must include the original tools definition."
@@ -1214,6 +1218,7 @@ def _to_config(self) -> AssistantAgentConfig:
12141218
model_client_stream=self._model_client_stream,
12151219
reflect_on_tool_use=self._reflect_on_tool_use,
12161220
tool_call_summary_format=self._tool_call_summary_format,
1221+
metadata=self._metadata,
12171222
)
12181223

12191224
@classmethod
@@ -1231,4 +1236,5 @@ def _from_config(cls, config: AssistantAgentConfig) -> Self:
12311236
model_client_stream=config.model_client_stream,
12321237
reflect_on_tool_use=config.reflect_on_tool_use,
12331238
tool_call_summary_format=config.tool_call_summary_format,
1239+
metadata=config.metadata,
12341240
)

0 commit comments

Comments
 (0)