Repository navigation
Expand file tree
/
Copy pathremote_http.py
More file actions
67 lines (58 loc) · 2.21 KB
/
Copy pathremote_http.py
File metadata and controls
67 lines (58 loc) · 2.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import asyncio
import os
from agent_framework import Agent, MCPStreamableHTTPTool
from agent_framework.foundry import FoundryChatClient
from azure.identity.aio import AzureCliCredential
def required(name: str) -> str:
value = os.getenv(name)
if not value:
raise RuntimeError(f"{name} is required")
return value
async def main() -> None:
mcp_url = required("AGENTIC_DATA_MCP_URL")
api_key = required("AGENTIC_DATA_API_KEY")
purpose = required("AGENTIC_DATA_PURPOSE")
instance_id = os.getenv("AGENTIC_DATA_INSTANCE_ID")
def headers(_: dict[str, object]) -> dict[str, str]:
return {
"Authorization": f"Bearer {api_key}",
"X-Agent-Purpose": purpose,
}
async with AzureCliCredential() as credential:
chat_client = FoundryChatClient(
project_endpoint=required("FOUNDRY_PROJECT_ENDPOINT"),
model=required("FOUNDRY_MODEL"),
credential=credential,
)
async with (
MCPStreamableHTTPTool(
name="agentic-data-kernel",
url=mcp_url,
header_provider=headers,
) as agentic_data,
Agent(
client=chat_client,
name="DurableOperationsAgent",
instructions=(
"Use Agentic Data Kernel as the durable source for "
"incident knowledge, conflicts, workflow state, effect "
"status, and causal explanation. Do not claim that an "
"external action succeeded unless the durable effect "
"record says it succeeded."
),
tools=agentic_data,
) as agent,
):
prompt = (
"Summarize the durable operational context and identify "
"unknown or conflicting claims."
)
if instance_id:
prompt += (
f" Inspect workflow {instance_id}, its effects, and "
"the causal trace around material decisions."
)
result = await agent.run(prompt)
print(result.text)
if __name__ == "__main__":
asyncio.run(main())