Add /ultraresearch-local for structured research combining local codebase analysis with external knowledge via parallel agent swarms. Produces research briefs with triangulation, confidence ratings, and source quality assessment. New command: /ultraresearch-local with modes --quick, --local, --external, --fg. New agents: research-orchestrator (opus), docs-researcher, community-researcher, security-researcher, contrarian-researcher, gemini-bridge (all sonnet). New template: research-brief-template.md. Integration: --research flag in /ultraplan-local accepts pre-built research briefs (up to 3), enriches the interview and exploration phases. Planning orchestrator cross-references brief findings during synthesis. Design principle: Context Engineering — right information to right agent at right time. Research briefs are structured artifacts in the pipeline: ultraresearch → brief → ultraplan --research → plan → ultraexecute. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
474 lines
9.7 KiB
Markdown
474 lines
9.7 KiB
Markdown
# Microsoft Agent Framework - Knowledge Base
|
|
|
|
**Last updated:** 2026-01
|
|
**Status:** GA (General Availability)
|
|
|
|
---
|
|
|
|
## Hva er Microsoft Agent Framework?
|
|
|
|
Microsoft Agent Framework er Microsofts SDK for å bygge AI-agenter i kode. Det er etterfølgeren til Semantic Kernel og tilbyr et unified rammeverk for agent-utvikling på tvers av Azure AI Foundry og standalone-applikasjoner.
|
|
|
|
**Nøkkelegenskaper:**
|
|
- Multi-agent orkestrering
|
|
- Tool/function calling
|
|
- Memory og state management
|
|
- Streaming og async support
|
|
- Azure AI Foundry-integrasjon
|
|
|
|
**Språk:** Python, C#, JavaScript/TypeScript
|
|
|
|
---
|
|
|
|
## Forhold til Semantic Kernel
|
|
|
|
| Aspekt | Semantic Kernel | Microsoft Agent Framework |
|
|
|--------|-----------------|---------------------------|
|
|
| **Status** | Vedlikeholdes fortsatt | Anbefalt for nye prosjekter |
|
|
| **Fokus** | LLM-orkestrering, plugins | Multi-agent systemer |
|
|
| **Abstraksjonsnivå** | Høy | Middels |
|
|
| **Azure-integrasjon** | God | Tight (Foundry-native) |
|
|
| **Memory** | Basic | Avansert (persistent) |
|
|
|
|
**Anbefaling:** Bruk Microsoft Agent Framework for nye prosjekter. Semantic Kernel-kode kan migreres gradvis.
|
|
|
|
---
|
|
|
|
## Kjernekomponenter
|
|
|
|
### Agent
|
|
|
|
En autonom enhet som kan:
|
|
- Motta instruksjoner
|
|
- Bruke verktøy (tools)
|
|
- Samarbeide med andre agenter
|
|
- Opprettholde tilstand
|
|
|
|
```python
|
|
from azure.ai.agent import Agent, AgentConfig
|
|
|
|
agent = Agent(
|
|
config=AgentConfig(
|
|
name="ResearchAgent",
|
|
instructions="Du er en forskningsassistent som finner fakta.",
|
|
model="gpt-4o",
|
|
tools=[search_tool, file_reader_tool]
|
|
)
|
|
)
|
|
```
|
|
|
|
### Tools
|
|
|
|
Funksjoner agenten kan kalle:
|
|
|
|
```python
|
|
from azure.ai.agent import tool
|
|
|
|
@tool
|
|
def search_web(query: str) -> str:
|
|
"""Søk på nettet etter informasjon."""
|
|
# Implementasjon
|
|
return results
|
|
|
|
@tool
|
|
def read_file(path: str) -> str:
|
|
"""Les innholdet i en fil."""
|
|
# Implementasjon
|
|
return content
|
|
```
|
|
|
|
### Memory
|
|
|
|
Lagre og hente kontekst på tvers av samtaler:
|
|
|
|
```python
|
|
from azure.ai.agent import Memory
|
|
|
|
memory = Memory(
|
|
type="persistent", # eller "session"
|
|
storage="cosmos_db" # eller "in_memory"
|
|
)
|
|
|
|
agent = Agent(
|
|
config=config,
|
|
memory=memory
|
|
)
|
|
```
|
|
|
|
### Multi-Agent Orchestration
|
|
|
|
Koordiner flere agenter:
|
|
|
|
```python
|
|
from azure.ai.agent import Swarm, Handoff
|
|
|
|
research_agent = Agent(name="Researcher", ...)
|
|
writer_agent = Agent(name="Writer", ...)
|
|
|
|
swarm = Swarm(
|
|
agents=[research_agent, writer_agent],
|
|
handoffs=[
|
|
Handoff(
|
|
from_agent="Researcher",
|
|
to_agent="Writer",
|
|
condition="research_complete"
|
|
)
|
|
]
|
|
)
|
|
|
|
result = await swarm.run("Skriv en rapport om AI-trender")
|
|
```
|
|
|
|
---
|
|
|
|
## Azure AI Foundry-integrasjon
|
|
|
|
Agent Framework er native integrert med Azure AI Foundry Agent Service.
|
|
|
|
### Deploye til Foundry
|
|
|
|
```python
|
|
from azure.ai.foundry import FoundryClient
|
|
|
|
client = FoundryClient(
|
|
endpoint="https://<workspace>.api.azureml.ms",
|
|
credential=DefaultAzureCredential()
|
|
)
|
|
|
|
# Deploye agent
|
|
deployment = client.agents.deploy(
|
|
agent=my_agent,
|
|
name="production-agent",
|
|
scaling={
|
|
"min_instances": 1,
|
|
"max_instances": 10
|
|
}
|
|
)
|
|
```
|
|
|
|
### Bruke Foundry Tools
|
|
|
|
Tilgang til 1,400+ Logic Apps connectors:
|
|
|
|
```python
|
|
from azure.ai.foundry import FoundryTools
|
|
|
|
tools = FoundryTools(client)
|
|
|
|
# Legg til SharePoint-tilgang
|
|
sharepoint = tools.get("sharepoint")
|
|
my_agent.add_tool(sharepoint)
|
|
|
|
# Legg til Fabric-tilgang
|
|
fabric = tools.get("fabric")
|
|
my_agent.add_tool(fabric)
|
|
```
|
|
|
|
---
|
|
|
|
## Patterns
|
|
|
|
### Pattern 1: RAG Agent
|
|
|
|
```python
|
|
from azure.ai.agent import Agent, tool
|
|
from azure.ai.search import SearchClient
|
|
|
|
search_client = SearchClient(...)
|
|
|
|
@tool
|
|
def search_documents(query: str) -> str:
|
|
"""Søk i kunnskapsbasen."""
|
|
results = search_client.search(query, top=5)
|
|
return "\n".join([r.content for r in results])
|
|
|
|
rag_agent = Agent(
|
|
name="KnowledgeAgent",
|
|
instructions="""
|
|
Du er en kunnskapsassistent. Bruk search_documents for å finne
|
|
relevant informasjon før du svarer. Siter alltid kilder.
|
|
""",
|
|
tools=[search_documents]
|
|
)
|
|
```
|
|
|
|
### Pattern 2: Supervisor-Worker
|
|
|
|
```python
|
|
from azure.ai.agent import Agent, Swarm
|
|
|
|
# Worker agents
|
|
researcher = Agent(name="Researcher", instructions="Finn fakta...")
|
|
writer = Agent(name="Writer", instructions="Skriv innhold...")
|
|
reviewer = Agent(name="Reviewer", instructions="Kvalitetssjekk...")
|
|
|
|
# Supervisor
|
|
supervisor = Agent(
|
|
name="Supervisor",
|
|
instructions="""
|
|
Du koordinerer arbeidet mellom Researcher, Writer og Reviewer.
|
|
1. Gi Researcher en research-oppgave
|
|
2. Gi Writer output fra Researcher
|
|
3. La Reviewer validere
|
|
4. Iterer hvis nødvendig
|
|
""",
|
|
sub_agents=[researcher, writer, reviewer]
|
|
)
|
|
```
|
|
|
|
### Pattern 3: Human-in-the-Loop
|
|
|
|
```python
|
|
from azure.ai.agent import Agent, Checkpoint
|
|
|
|
@checkpoint
|
|
async def approve_action(action: str) -> bool:
|
|
"""Krever menneskelig godkjenning."""
|
|
approval = await request_human_approval(action)
|
|
return approval.approved
|
|
|
|
agent = Agent(
|
|
name="ActionAgent",
|
|
instructions="Utfør handlinger, men be om godkjenning først.",
|
|
checkpoints=[approve_action]
|
|
)
|
|
```
|
|
|
|
### Pattern 4: Streaming Response
|
|
|
|
```python
|
|
from azure.ai.agent import Agent
|
|
|
|
agent = Agent(...)
|
|
|
|
# Streaming for responsiv UI
|
|
async for chunk in agent.run_stream("Forklar kvantefysikk"):
|
|
print(chunk.text, end="", flush=True)
|
|
```
|
|
|
|
---
|
|
|
|
## Memory Strategies
|
|
|
|
### In-Memory (Session)
|
|
|
|
```python
|
|
memory = Memory(type="session")
|
|
# Varer kun for denne sesjonen
|
|
# Raskest, men ingen persistens
|
|
```
|
|
|
|
### Cosmos DB (Persistent)
|
|
|
|
```python
|
|
memory = Memory(
|
|
type="persistent",
|
|
storage="cosmos_db",
|
|
connection_string="...",
|
|
database="agents",
|
|
container="conversations"
|
|
)
|
|
# Persisterer på tvers av sesjoner
|
|
# Støtter vector search for semantic retrieval
|
|
```
|
|
|
|
### Redis (Distributed)
|
|
|
|
```python
|
|
memory = Memory(
|
|
type="distributed",
|
|
storage="redis",
|
|
connection_string="..."
|
|
)
|
|
# For multi-instance deployment
|
|
# Lavere latency enn Cosmos DB
|
|
```
|
|
|
|
---
|
|
|
|
## Observability
|
|
|
|
### Tracing
|
|
|
|
```python
|
|
from azure.ai.agent import enable_tracing
|
|
from opentelemetry.sdk.trace.export import ConsoleSpanExporter
|
|
|
|
enable_tracing(
|
|
exporter=ConsoleSpanExporter(),
|
|
# eller: AzureMonitorExporter()
|
|
)
|
|
|
|
# Alle agent-operasjoner logges nå
|
|
```
|
|
|
|
### Metrics
|
|
|
|
```python
|
|
from azure.ai.agent import metrics
|
|
|
|
# Agent-level metrics
|
|
agent.on_run_complete(lambda m: log_metrics(m))
|
|
|
|
# Metrics inkluderer:
|
|
# - Token usage
|
|
# - Tool calls
|
|
# - Latency
|
|
# - Error rates
|
|
```
|
|
|
|
### Azure Monitor Integration
|
|
|
|
```python
|
|
from azure.monitor.opentelemetry import configure_azure_monitor
|
|
|
|
configure_azure_monitor(
|
|
connection_string="InstrumentationKey=..."
|
|
)
|
|
|
|
# All telemetry -> Application Insights
|
|
```
|
|
|
|
---
|
|
|
|
## Security
|
|
|
|
### Managed Identity
|
|
|
|
```python
|
|
from azure.identity import DefaultAzureCredential
|
|
|
|
agent = Agent(
|
|
credential=DefaultAzureCredential(),
|
|
# Ingen secrets i koden
|
|
)
|
|
```
|
|
|
|
### Content Safety
|
|
|
|
```python
|
|
from azure.ai.contentsafety import ContentSafetyClient
|
|
|
|
safety = ContentSafetyClient(...)
|
|
|
|
@tool
|
|
def safe_generate(prompt: str) -> str:
|
|
# Sjekk input
|
|
input_check = safety.analyze_text(prompt)
|
|
if input_check.harmful:
|
|
raise ValueError("Harmful input detected")
|
|
|
|
# Generer
|
|
response = llm.generate(prompt)
|
|
|
|
# Sjekk output
|
|
output_check = safety.analyze_text(response)
|
|
if output_check.harmful:
|
|
return "Kunne ikke generere trygt svar"
|
|
|
|
return response
|
|
```
|
|
|
|
### Tool Permission Scoping
|
|
|
|
```python
|
|
@tool(
|
|
permissions=["files.read"], # Begrensede permissions
|
|
require_confirmation=True # Krev bekreftelse
|
|
)
|
|
def read_sensitive_file(path: str) -> str:
|
|
...
|
|
```
|
|
|
|
---
|
|
|
|
## Migration fra Semantic Kernel
|
|
|
|
### Kernel → Agent
|
|
|
|
```python
|
|
# Semantic Kernel
|
|
kernel = Kernel()
|
|
kernel.add_plugin(MyPlugin())
|
|
result = await kernel.invoke(function, input)
|
|
|
|
# Agent Framework
|
|
agent = Agent(tools=[my_tool])
|
|
result = await agent.run(input)
|
|
```
|
|
|
|
### Plugins → Tools
|
|
|
|
```python
|
|
# Semantic Kernel plugin
|
|
@kernel_function
|
|
def my_function(input: str) -> str:
|
|
return process(input)
|
|
|
|
# Agent Framework tool
|
|
@tool
|
|
def my_function(input: str) -> str:
|
|
return process(input)
|
|
```
|
|
|
|
### Planners → Orchestration
|
|
|
|
```python
|
|
# Semantic Kernel planner
|
|
planner = SequentialPlanner(kernel)
|
|
plan = await planner.create_plan(goal)
|
|
result = await plan.invoke()
|
|
|
|
# Agent Framework
|
|
agent = Agent(
|
|
instructions=goal,
|
|
tools=[...]
|
|
)
|
|
result = await agent.run() # Automatisk planning
|
|
```
|
|
|
|
---
|
|
|
|
## For Cosmo: Beslutningsveiledning
|
|
|
|
### Når anbefale Agent Framework
|
|
|
|
1. **Utviklerteam** som bygger AI-applikasjoner
|
|
2. **Multi-agent systemer** med kompleks orkestrering
|
|
3. **Tight Azure-integrasjon** via Foundry Agent Service
|
|
4. **Custom logic** som krever kode
|
|
5. **Produksjonskrav** (observability, scaling, security)
|
|
|
|
### Når anbefale Copilot Studio istedenfor
|
|
|
|
1. **Citizen developers** uten kodeerfaring
|
|
2. **Rask prototyping** av chatbots
|
|
3. **Standard scenarios** (Q&A, IT helpdesk)
|
|
4. **Power Platform-økosystem** allerede i bruk
|
|
|
|
### Når anbefale direkte Azure OpenAI istedenfor
|
|
|
|
1. **Enkle API-kall** uten orkestrering
|
|
2. **Minimal kompleksitet** påkrevd
|
|
3. **Eksisterende SDK-integrasjon** (OpenAI SDK)
|
|
|
|
### Spørsmål å stille kunden
|
|
|
|
1. "Har dere utviklere som kan skrive Python/C#/TypeScript?"
|
|
2. "Trenger dere at flere agenter samarbeider?"
|
|
3. "Hvilke systemer må agenten integrere med?"
|
|
4. "Hva er kravene til observability og logging?"
|
|
5. "Skal løsningen kjøre i Azure, on-prem, eller hybrid?"
|
|
|
|
---
|
|
|
|
## Ressurser
|
|
|
|
- [Agent Framework Documentation](https://learn.microsoft.com/azure/ai-services/agents)
|
|
- [Azure AI Foundry Agent Service](https://learn.microsoft.com/azure/ai-foundry/agent-service)
|
|
- [Migration Guide from Semantic Kernel](https://learn.microsoft.com/azure/ai-services/agents/migrate-semantic-kernel)
|
|
- [GitHub Samples](https://github.com/azure-samples/ai-agent-framework)
|
|
|
|
---
|
|
|
|
*Sist oppdatert: Januar 2026*
|