mirror of
https://github.com/microsoft/agent-framework.git
synced 2026-06-16 21:04:09 +08:00
Python: [BREAKING]: removed display_name, renamed context_providers, middleware and AggregateContextProvider (#3139)
* removed display_name, renamed context_providers, middleware and AggregateContextProvider * fixes * fixed test * testfix * removed mistakenly put back test * updated new test * rename middlewares to middleware * middleware fixes
This commit is contained in:
committed by
GitHub
Unverified
parent
ef44fb4960
commit
203fb7b1c4
@@ -346,8 +346,8 @@ class EntityDiscovery:
|
||||
instructions = None
|
||||
model = None
|
||||
chat_client_type = None
|
||||
context_providers_list = None
|
||||
middleware_list = None
|
||||
context_provider_list = None
|
||||
middlewares_list = None
|
||||
|
||||
if entity_type == "agent":
|
||||
from ._utils import extract_agent_metadata
|
||||
@@ -356,8 +356,8 @@ class EntityDiscovery:
|
||||
instructions = agent_meta["instructions"]
|
||||
model = agent_meta["model"]
|
||||
chat_client_type = agent_meta["chat_client_type"]
|
||||
context_providers_list = agent_meta["context_providers"]
|
||||
middleware_list = agent_meta["middleware"]
|
||||
context_provider_list = agent_meta["context_provider"]
|
||||
middlewares_list = agent_meta["middleware"]
|
||||
|
||||
# Log helpful info about agent capabilities (before creating EntityInfo)
|
||||
if entity_type == "agent":
|
||||
@@ -395,8 +395,8 @@ class EntityDiscovery:
|
||||
instructions=instructions,
|
||||
model_id=model,
|
||||
chat_client_type=chat_client_type,
|
||||
context_providers=context_providers_list,
|
||||
middleware=middleware_list,
|
||||
context_provider=context_provider_list,
|
||||
middleware=middlewares_list,
|
||||
executors=tools_list if entity_type == "workflow" else [],
|
||||
input_schema={"type": "string"}, # Default schema
|
||||
start_executor_id=tools_list[0] if tools_list and entity_type == "workflow" else None,
|
||||
@@ -829,8 +829,8 @@ class EntityDiscovery:
|
||||
instructions = None
|
||||
model = None
|
||||
chat_client_type = None
|
||||
context_providers_list = None
|
||||
middleware_list = None
|
||||
context_provider_list = None
|
||||
middlewares_list = None
|
||||
|
||||
if obj_type == "agent":
|
||||
from ._utils import extract_agent_metadata
|
||||
@@ -839,8 +839,8 @@ class EntityDiscovery:
|
||||
instructions = agent_meta["instructions"]
|
||||
model = agent_meta["model"]
|
||||
chat_client_type = agent_meta["chat_client_type"]
|
||||
context_providers_list = agent_meta["context_providers"]
|
||||
middleware_list = agent_meta["middleware"]
|
||||
context_provider_list = agent_meta["context_provider"]
|
||||
middlewares_list = agent_meta["middleware"]
|
||||
|
||||
entity_info = EntityInfo(
|
||||
id=entity_id,
|
||||
@@ -852,8 +852,8 @@ class EntityDiscovery:
|
||||
instructions=instructions,
|
||||
model_id=model,
|
||||
chat_client_type=chat_client_type,
|
||||
context_providers=context_providers_list,
|
||||
middleware=middleware_list,
|
||||
context_provider=context_provider_list,
|
||||
middleware=middlewares_list,
|
||||
metadata={
|
||||
"module_path": module_path,
|
||||
"entity_type": obj_type,
|
||||
|
||||
@@ -32,7 +32,7 @@ def extract_agent_metadata(entity_object: Any) -> dict[str, Any]:
|
||||
"instructions": None,
|
||||
"model": None,
|
||||
"chat_client_type": None,
|
||||
"context_providers": None,
|
||||
"context_provider": None,
|
||||
"middleware": None,
|
||||
}
|
||||
|
||||
@@ -60,20 +60,20 @@ def extract_agent_metadata(entity_object: Any) -> dict[str, Any]:
|
||||
and entity_object.context_provider
|
||||
and hasattr(entity_object.context_provider, "__class__")
|
||||
):
|
||||
metadata["context_providers"] = [entity_object.context_provider.__class__.__name__] # type: ignore
|
||||
metadata["context_provider"] = [entity_object.context_provider.__class__.__name__] # type: ignore
|
||||
|
||||
# Try to get middleware
|
||||
if hasattr(entity_object, "middleware") and entity_object.middleware:
|
||||
middleware_list: list[str] = []
|
||||
middlewares_list: list[str] = []
|
||||
for m in entity_object.middleware:
|
||||
# Try multiple ways to get a good name for middleware
|
||||
if hasattr(m, "__name__"): # Function or callable
|
||||
middleware_list.append(m.__name__)
|
||||
middlewares_list.append(m.__name__)
|
||||
elif hasattr(m, "__class__"): # Class instance
|
||||
middleware_list.append(m.__class__.__name__)
|
||||
middlewares_list.append(m.__class__.__name__)
|
||||
else:
|
||||
middleware_list.append(str(m))
|
||||
metadata["middleware"] = middleware_list # type: ignore
|
||||
middlewares_list.append(str(m))
|
||||
metadata["middleware"] = middlewares_list # type: ignore
|
||||
|
||||
return metadata
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ class EntityInfo(BaseModel):
|
||||
instructions: str | None = None
|
||||
model_id: str | None = None
|
||||
chat_client_type: str | None = None
|
||||
context_providers: list[str] | None = None
|
||||
context_provider: list[str] | None = None
|
||||
middleware: list[str] | None = None
|
||||
|
||||
# Workflow-specific fields (populated only for detailed info requests)
|
||||
|
||||
+8
-12
@@ -179,10 +179,10 @@ export function AgentDetailsModal({
|
||||
</DetailCard>
|
||||
)}
|
||||
|
||||
{/* Middleware */}
|
||||
{/* Middlewares */}
|
||||
{agent.middleware && agent.middleware.length > 0 && (
|
||||
<DetailCard
|
||||
title={`Middleware (${agent.middleware.length})`}
|
||||
title={`Middlewares (${agent.middleware.length})`}
|
||||
icon={<Package className="h-4 w-4 text-muted-foreground" />}
|
||||
>
|
||||
<ul className="space-y-1">
|
||||
@@ -195,20 +195,16 @@ export function AgentDetailsModal({
|
||||
</DetailCard>
|
||||
)}
|
||||
|
||||
{/* Context Providers */}
|
||||
{agent.context_providers && agent.context_providers.length > 0 && (
|
||||
{/* Context Provider */}
|
||||
{agent.context_provider && (
|
||||
<DetailCard
|
||||
title={`Context Providers (${agent.context_providers.length})`}
|
||||
title="Context Provider"
|
||||
icon={<Database className="h-4 w-4 text-muted-foreground" />}
|
||||
className={!agent.middleware || agent.middleware.length === 0 ? "md:col-start-2" : ""}
|
||||
>
|
||||
<ul className="space-y-1">
|
||||
{agent.context_providers.map((cp, index) => (
|
||||
<li key={index} className="font-mono text-xs text-foreground">
|
||||
• {cp}
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
<div className="font-mono text-xs text-foreground">
|
||||
{agent.context_provider}
|
||||
</div>
|
||||
</DetailCard>
|
||||
)}
|
||||
</div>
|
||||
|
||||
@@ -42,7 +42,7 @@ interface BackendEntityInfo {
|
||||
instructions?: string;
|
||||
model_id?: string;
|
||||
chat_client_type?: string;
|
||||
context_providers?: string[];
|
||||
context_provider?: string[];
|
||||
middleware?: string[];
|
||||
// Workflow-specific fields (present when type === "workflow")
|
||||
executors?: string[];
|
||||
@@ -77,7 +77,7 @@ const MAX_RETRY_ATTEMPTS = 10; // Max 10 retries (~30 seconds with exponential b
|
||||
function getBackendUrl(): string {
|
||||
const stored = localStorage.getItem("devui_backend_url");
|
||||
if (stored) return stored;
|
||||
|
||||
|
||||
return DEFAULT_API_BASE_URL;
|
||||
}
|
||||
|
||||
@@ -221,13 +221,13 @@ class ApiClient {
|
||||
instructions: entity.instructions,
|
||||
model_id: entity.model_id,
|
||||
chat_client_type: entity.chat_client_type,
|
||||
context_providers: entity.context_providers,
|
||||
context_provider: entity.context_provider,
|
||||
middleware: entity.middleware,
|
||||
};
|
||||
} else {
|
||||
// Workflow - prefer executors field, fall back to tools for backward compatibility
|
||||
const executorList = entity.executors || entity.tools || [];
|
||||
|
||||
|
||||
// Determine start_executor_id: use entity value, or first executor if it's a string
|
||||
let startExecutorId = entity.start_executor_id || "";
|
||||
if (!startExecutorId && executorList.length > 0) {
|
||||
@@ -236,7 +236,7 @@ class ApiClient {
|
||||
startExecutorId = firstExecutor;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return {
|
||||
id: entity.id,
|
||||
name: entity.name,
|
||||
@@ -493,10 +493,10 @@ class ApiClient {
|
||||
if (!resumeResponseId) {
|
||||
currentResponseId = storedState.responseId;
|
||||
}
|
||||
|
||||
|
||||
lastSequenceNumber = storedState.lastSequenceNumber;
|
||||
lastMessageId = storedState.lastMessageId;
|
||||
|
||||
|
||||
// Replay stored events only if we're not explicitly resuming
|
||||
// (explicit resume means the caller already has the events)
|
||||
if (!resumeResponseId) {
|
||||
|
||||
@@ -39,8 +39,8 @@ export interface AgentInfo {
|
||||
instructions?: string;
|
||||
model_id?: string;
|
||||
chat_client_type?: string;
|
||||
context_providers?: string[];
|
||||
middleware?: string[];
|
||||
context_provider?: string | undefined;
|
||||
middleware?: string[] | undefined;
|
||||
}
|
||||
|
||||
// JSON Schema types for workflow input
|
||||
|
||||
@@ -91,10 +91,6 @@ class NonStreamingAgent:
|
||||
name = "Non-Streaming Agent"
|
||||
description = "Agent without run_stream"
|
||||
|
||||
@property
|
||||
def display_name(self):
|
||||
return self.name
|
||||
|
||||
async def run(self, messages=None, *, thread=None, **kwargs):
|
||||
return AgentRunResponse(
|
||||
messages=[ChatMessage(
|
||||
|
||||
@@ -575,10 +575,6 @@ async def test_executor_handles_non_streaming_agent():
|
||||
name = "Non-Streaming Test Agent"
|
||||
description = "Test agent without run_stream()"
|
||||
|
||||
@property
|
||||
def display_name(self):
|
||||
return self.name
|
||||
|
||||
async def run(self, messages=None, *, thread=None, **kwargs):
|
||||
return AgentRunResponse(
|
||||
messages=[ChatMessage(role=Role.ASSISTANT, contents=[TextContent(text=f"Processed: {messages}")])],
|
||||
|
||||
Reference in New Issue
Block a user