Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion python/packages/a2a/agent_framework_a2a/_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ async def run(
"""
# Collect all updates and use framework to consolidate updates into response
updates = [update async for update in self.run_stream(messages, thread=thread, **kwargs)]
return AgentResponse.from_agent_run_response_updates(updates)
return AgentResponse.from_agent_response_updates(updates)

async def run_stream(
self,
Expand Down
2 changes: 1 addition & 1 deletion python/packages/ag-ui/agent_framework_ag_ui/_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -862,7 +862,7 @@ async def run_agent_stream(
from pydantic import BaseModel

logger.info(f"Processing structured output, update count: {len(all_updates)}")
final_response = AgentResponse.from_agent_run_response_updates(all_updates, output_format_type=response_format)
final_response = AgentResponse.from_agent_response_updates(all_updates, output_format_type=response_format)

if final_response.value and isinstance(final_response.value, BaseModel):
response_dict = final_response.value.model_dump(mode="json", exclude_none=True)
Expand Down
2 changes: 1 addition & 1 deletion python/packages/core/agent_framework/_agents.py
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ async def agent_wrapper(**kwargs: Any) -> str:
stream_callback(update)

# Create final text from accumulated updates
return AgentResponse.from_agent_run_response_updates(response_updates).text
return AgentResponse.from_agent_response_updates(response_updates).text

agent_tool: FunctionTool[BaseModel, str] = FunctionTool(
name=tool_name,
Expand Down
8 changes: 4 additions & 4 deletions python/packages/core/agent_framework/_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -2452,7 +2452,7 @@ class AgentResponse(SerializationMixin, Generic[TResponseModel]):

# Combine streaming updates
updates = [...] # List of AgentResponseUpdate objects
response = AgentResponse.from_agent_run_response_updates(updates)
response = AgentResponse.from_agent_response_updates(updates)

# Serialization - to_dict and from_dict
response_dict = response.to_dict()
Expand Down Expand Up @@ -2567,7 +2567,7 @@ def user_input_requests(self) -> list[Content]:

@overload
@classmethod
def from_agent_run_response_updates(
def from_agent_response_updates(
cls: type["AgentResponse[Any]"],
updates: Sequence["AgentResponseUpdate"],
*,
Expand All @@ -2576,15 +2576,15 @@ def from_agent_run_response_updates(

@overload
@classmethod
def from_agent_run_response_updates(
def from_agent_response_updates(
cls: type["AgentResponse[Any]"],
updates: Sequence["AgentResponseUpdate"],
*,
output_format_type: None = None,
) -> "AgentResponse[Any]": ...

@classmethod
def from_agent_run_response_updates(
def from_agent_response_updates(
cls: type[TAgentRunResponse],
updates: Sequence["AgentResponseUpdate"],
*,
Expand Down
8 changes: 4 additions & 4 deletions python/packages/core/agent_framework/_workflows/_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ def merge_updates(updates: list[AgentResponseUpdate], response_id: str) -> Agent
- Group updates by response_id; within each response_id, group by message_id and keep a dangling bucket for
updates without message_id.
- Convert each group (per message and dangling) into an intermediate AgentResponse via
AgentResponse.from_agent_run_response_updates, then sort by created_at and merge.
AgentResponse.from_agent_response_updates, then sort by created_at and merge.
- Append messages from updates without any response_id at the end (global dangling), while aggregating metadata.

Args:
Expand Down Expand Up @@ -548,9 +548,9 @@ def _add_raw(value: object) -> None:
per_message_responses: list[AgentResponse] = []
for _, msg_updates in by_msg.items():
if msg_updates:
per_message_responses.append(AgentResponse.from_agent_run_response_updates(msg_updates))
per_message_responses.append(AgentResponse.from_agent_response_updates(msg_updates))
if dangling:
per_message_responses.append(AgentResponse.from_agent_run_response_updates(dangling))
per_message_responses.append(AgentResponse.from_agent_response_updates(dangling))

per_message_responses.sort(key=lambda r: _parse_dt(r.created_at))

Expand Down Expand Up @@ -584,7 +584,7 @@ def _add_raw(value: object) -> None:
# These are updates that couldn't be associated with any response_id
# (e.g., orphan FunctionResultContent with no matching FunctionCallContent)
if global_dangling:
flattened = AgentResponse.from_agent_run_response_updates(global_dangling)
flattened = AgentResponse.from_agent_response_updates(global_dangling)
final_messages.extend(flattened.messages)
if flattened.usage_details:
merged_usage = add_usage_details(merged_usage, flattened.usage_details) # type: ignore[arg-type]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -377,12 +377,12 @@ async def _run_agent_streaming(self, ctx: WorkflowContext) -> AgentResponse | No
# Build the final AgentResponse from the collected updates
if isinstance(self._agent, ChatAgent):
response_format = self._agent.default_options.get("response_format")
response = AgentResponse.from_agent_run_response_updates(
response = AgentResponse.from_agent_response_updates(
updates,
output_format_type=response_format,
)
else:
response = AgentResponse.from_agent_run_response_updates(updates)
response = AgentResponse.from_agent_response_updates(updates)

# Handle any user input requests after the streaming completes
if user_input_requests:
Expand Down
2 changes: 1 addition & 1 deletion python/packages/core/agent_framework/observability.py
Original file line number Diff line number Diff line change
Expand Up @@ -1450,7 +1450,7 @@ async def trace_run_streaming(
capture_exception(span=span, exception=exception, timestamp=time_ns())
raise
else:
response = AgentResponse.from_agent_run_response_updates(all_updates)
response = AgentResponse.from_agent_response_updates(all_updates)
attributes = _get_response_attributes(attributes, response, capture_usage=capture_usage)
_capture_response(span=span, attributes=attributes)
if OBSERVABILITY_SETTINGS.SENSITIVE_DATA_ENABLED and response.messages:
Expand Down
2 changes: 1 addition & 1 deletion python/packages/core/tests/core/test_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -1129,7 +1129,7 @@ def test_agent_run_response_text_property_empty() -> None:

def test_agent_run_response_from_updates(agent_response_update: AgentResponseUpdate) -> None:
Copy link

Copilot AI Feb 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test name still refers to agent_run_response even though the API under test is now AgentResponse.from_agent_response_updates. Renaming the test to match the updated terminology would keep the suite consistent and easier to search/understand.

Suggested change
def test_agent_run_response_from_updates(agent_response_update: AgentResponseUpdate) -> None:
def test_agent_response_from_agent_response_updates(agent_response_update: AgentResponseUpdate) -> None:

Copilot uses AI. Check for mistakes.
updates = [agent_response_update, agent_response_update]
response = AgentResponse.from_agent_run_response_updates(updates)
response = AgentResponse.from_agent_response_updates(updates)
assert len(response.messages) > 0
assert response.text == "Test contentTest content"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ async def handle_invoke_azure_agent(ctx: ActionContext) -> AsyncGenerator[Workfl
tool_calls.extend(chunk.tool_calls)

# Build consolidated response from updates
response = AgentResponse.from_agent_run_response_updates(updates)
response = AgentResponse.from_agent_response_updates(updates)
text = response.text
response_messages = response.messages

Expand Down Expand Up @@ -581,7 +581,7 @@ async def handle_invoke_prompt_agent(ctx: ActionContext) -> AsyncGenerator[Workf
)

# Build consolidated response from updates
response = AgentResponse.from_agent_run_response_updates(updates)
response = AgentResponse.from_agent_response_updates(updates)
text = response.text
response_messages = response.messages

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ async def _consume_stream(
await self._notify_stream_update(update, callback_context)

if updates:
response = AgentResponse.from_agent_run_response_updates(updates)
response = AgentResponse.from_agent_response_updates(updates)
else:
logger.debug("[AgentEntity] No streaming updates received; creating empty response")
response = AgentResponse(messages=[])
Expand Down
Loading