Skip to content

A programming framework for agentic AI

AssistantAgent.metadata for user/application identity information associated with the agent. #6048 (#6057)

tongyu47ffaccba13d
diff --git a/docs/dotnet/core/toc.yml b/docs/dotnet/core/toc.yml
index cc0156551..1f0cc20a6 100644
--- a/docs/dotnet/core/toc.yml
+++ b/docs/dotnet/core/toc.yml
@@ -7,4 +7,4 @@
- name: Differences from Python
href: differences-from-python.md
- name: Protobuf message types
- href: protobuf-message-types.md
\ No newline at end of file
+ href: protobuf-message-types.md
diff --git a/docs/dotnet/docfx.json b/docs/dotnet/docfx.json
index f43779dd3..cb44b5c6b 100644
--- a/docs/dotnet/docfx.json
+++ b/docs/dotnet/docfx.json
@@ -73,4 +73,4 @@
"keepFileLink": false,
"disableGitFeatures": false
}
-}
\ No newline at end of file
+}
diff --git a/python/packages/autogen-agentchat/src/autogen_agentchat/agents/_assistant_agent.py b/python/packages/autogen-agentchat/src/autogen_agentchat/agents/_assistant_agent.py
index 4d001c0ab..92d2ccaa4 100644
--- a/python/packages/autogen-agentchat/src/autogen_agentchat/agents/_assistant_agent.py
+++ b/python/packages/autogen-agentchat/src/autogen_agentchat/agents/_assistant_agent.py
@@ -73,6 +73,7 @@ class AssistantAgentConfig(BaseModel):
model_client_stream: bool = False
reflect_on_tool_use: bool
tool_call_summary_format: str
+ metadata: Dict[str, str] | None = None
class AssistantAgent(BaseChatAgent, Component[AssistantAgentConfig]):
@@ -169,6 +170,7 @@ class AssistantAgent(BaseChatAgent, Component[AssistantAgentConfig]):
Available variables: `{tool_name}`, `{arguments}`, `{result}`.
For example, `"{tool_name}: {result}"` will create a summary like `"tool_name: result"`.
memory (Sequence[Memory] | None, optional): The memory store to use for the agent. Defaults to `None`.
+ metadata (Dict[str, str] | None, optional): Optional metadata for tracking.
Raises:
ValueError: If tool names are not unique.
@@ -613,8 +615,10 @@ class AssistantAgent(BaseChatAgent, Component[AssistantAgentConfig]):
reflect_on_tool_use: bool = False,
tool_call_summary_format: str = "{result}",
memory: Sequence[Memory] | None = None,
+ metadata: Dict[str, str] | None = None,
):
super().__init__(name=name, description=description)
+ self._metadata = metadata or {}
if reflect_on_tool_use and ModelFamily.is_claude(model_client.model_info["family"]):
warnings.warn(
"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 @@ class AssistantAgent(BaseChatAgent, Component[AssistantAgentConfig]):
model_client_stream=self._model_client_stream,
reflect_on_tool_use=self._reflect_on_tool_use,
tool_call_summary_format=self._tool_call_summary_format,
+ metadata=self._metadata,
)
@classmethod
@@ -1231,4 +1236,5 @@ class AssistantAgent(BaseChatAgent, Component[AssistantAgentConfig]):
model_client_stream=config.model_client_stream,
reflect_on_tool_use=config.reflect_on_tool_use,
tool_call_summary_format=config.tool_call_summary_format,
+ metadata=config.metadata,
)