Skip to content

Commit 7fa9900

Browse files
committed
Upgraded tto latest MAF and addressed breaking changes
1 parent 183eff7 commit 7fa9900

6 files changed

Lines changed: 21 additions & 29 deletions

File tree

examples/agent_knowledge_aisearch.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,6 @@
8787
search_credential = DefaultAzureCredential()
8888

8989
search_provider = AzureAISearchContextProvider(
90-
source_id="azure-ai-search",
9190
endpoint=SEARCH_ENDPOINT,
9291
credential=search_credential,
9392
knowledge_base_name=KNOWLEDGE_BASE_NAME,

examples/agent_summarization.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
AgentContext,
4444
AgentMiddleware,
4545
AgentResponse,
46+
InMemoryHistoryProvider,
4647
Message,
4748
tool,
4849
)
@@ -139,10 +140,6 @@ class SummarizationMiddleware(AgentMiddleware):
139140
with a single summary message before the agent processes the next turn.
140141
"""
141142

142-
# Key used by the default InMemoryHistoryProvider to store messages
143-
# https://github.com/microsoft/agent-framework/issues/3941
144-
HISTORY_STATE_KEY = "memory"
145-
146143
def __init__(
147144
self,
148145
client: OpenAIChatClient,
@@ -186,7 +183,7 @@ async def process(
186183

187184
# Before the agent runs: check if we should compact the history
188185
if session and self.context_tokens > self.token_threshold:
189-
history = session.state.get(self.HISTORY_STATE_KEY, {}).get("messages", [])
186+
history = session.state.get(InMemoryHistoryProvider.DEFAULT_SOURCE_ID, {}).get("messages", [])
190187
if len(history) > 2:
191188
logger.info(
192189
"[📝 Summarization] Token usage (%d) exceeds threshold (%d). "
@@ -204,7 +201,7 @@ async def process(
204201
)
205202

206203
# Replace session history with a single summary message
207-
session.state[self.HISTORY_STATE_KEY]["messages"] = [
204+
session.state[InMemoryHistoryProvider.DEFAULT_SOURCE_ID]["messages"] = [
208205
Message(role="assistant", text=f"[Summary of earlier conversation]\n{summary_text}"),
209206
]
210207

examples/spanish/agent_knowledge_aisearch.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@
8686
search_credential = DefaultAzureCredential()
8787

8888
search_provider = AzureAISearchContextProvider(
89-
source_id="azure-ai-search",
9089
endpoint=SEARCH_ENDPOINT,
9190
credential=search_credential,
9291
knowledge_base_name=KNOWLEDGE_BASE_NAME,

examples/spanish/agent_summarization.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
AgentContext,
4343
AgentMiddleware,
4444
AgentResponse,
45+
InMemoryHistoryProvider,
4546
Message,
4647
tool,
4748
)
@@ -138,10 +139,6 @@ class SummarizationMiddleware(AgentMiddleware):
138139
por un único mensaje de resumen antes de procesar el siguiente turno.
139140
"""
140141

141-
# Key used by the default InMemoryHistoryProvider to store messages
142-
# https://github.com/microsoft/agent-framework/issues/3941
143-
HISTORY_STATE_KEY = "memory"
144-
145142
def __init__(
146143
self,
147144
client: OpenAIChatClient,
@@ -185,7 +182,7 @@ async def process(
185182

186183
# Antes de ejecutar el agente: revisar si hay que compactar el historial
187184
if session and self.context_tokens > self.token_threshold:
188-
history = session.state.get(self.HISTORY_STATE_KEY, {}).get("messages", [])
185+
history = session.state.get(InMemoryHistoryProvider.DEFAULT_SOURCE_ID, {}).get("messages", [])
189186
if len(history) > 2:
190187
logger.info(
191188
"[📝 Resumen] Uso de tokens (%d) excede el umbral (%d). "
@@ -203,7 +200,7 @@ async def process(
203200
)
204201

205202
# Reemplazar el historial de la sesión con un único mensaje de resumen
206-
session.state[self.HISTORY_STATE_KEY]["messages"] = [
203+
session.state[InMemoryHistoryProvider.DEFAULT_SOURCE_ID]["messages"] = [
207204
Message(role="assistant", text=f"[Resumen de la conversación anterior]\n{summary_text}"),
208205
]
209206

pyproject.toml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ dependencies = [
1818
"psycopg[binary]",
1919
"pgvector",
2020
"azure-ai-evaluation[redteam]>=1.15.0",
21-
"agent-framework-core @ git+https://github.com/microsoft/agent-framework.git@fc9c81b0b11170bdab8fa2d42bb96981e65fd270#subdirectory=python/packages/core",
22-
"agent-framework-devui @ git+https://github.com/microsoft/agent-framework.git@fc9c81b0b11170bdab8fa2d42bb96981e65fd270#subdirectory=python/packages/devui",
23-
"agent-framework-redis @ git+https://github.com/microsoft/agent-framework.git@fc9c81b0b11170bdab8fa2d42bb96981e65fd270#subdirectory=python/packages/redis",
24-
"agent-framework-mem0 @ git+https://github.com/microsoft/agent-framework.git@fc9c81b0b11170bdab8fa2d42bb96981e65fd270#subdirectory=python/packages/mem0",
25-
"agent-framework-azure-ai-search @ git+https://github.com/microsoft/agent-framework.git@fc9c81b0b11170bdab8fa2d42bb96981e65fd270#subdirectory=python/packages/azure-ai-search",
21+
"agent-framework-core @ git+https://github.com/microsoft/agent-framework.git@main#subdirectory=python/packages/core",
22+
"agent-framework-devui @ git+https://github.com/microsoft/agent-framework.git@main#subdirectory=python/packages/devui",
23+
"agent-framework-redis @ git+https://github.com/microsoft/agent-framework.git@main#subdirectory=python/packages/redis",
24+
"agent-framework-mem0 @ git+https://github.com/microsoft/agent-framework.git@main#subdirectory=python/packages/mem0",
25+
"agent-framework-azure-ai-search @ git+https://github.com/microsoft/agent-framework.git@main#subdirectory=python/packages/azure-ai-search",
2626
]
2727

2828
[tool.ruff]

uv.lock

Lines changed: 10 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)