Python: Add samples syntax checking with pyright (#3710)

* Add samples syntax checking with pyright

- Add pyrightconfig.samples.json with relaxed type checking but import validation
- Add samples-syntax poe task to check samples for syntax and import errors
- Add samples-syntax to check and pre-commit-check tasks
- Fix 78 sample errors:
  - Update workflow builder imports to use agent_framework_orchestrations
  - Change content type isinstance checks to content.type comparisons
  - Use Content factory methods instead of removed content type classes
  - Fix TypedDict access patterns for Annotation
  - Fix various API mismatches (normalize_messages, ChatMessage.text, role)

* fixed a bunch of samples and tweaks to pre-commit

* updated lock

* updated lock

* fixes

* added lint to samples
This commit is contained in:
Eduard van Valkenburg
2026-02-07 08:10:47 +01:00
committed by GitHub
Unverified
parent 74ac470a56
commit 390f93344c
83 changed files with 606 additions and 498 deletions
@@ -7,7 +7,7 @@ to other specialized agents based on the task requirements.
import asyncio
from agent_framework import WorkflowEvent
from agent_framework import AgentResponseUpdate, WorkflowEvent
from orderedmultidict import Any
@@ -99,7 +99,6 @@ async def run_autogen() -> None:
async def run_agent_framework() -> None:
"""Agent Framework's HandoffBuilder for agent coordination."""
from agent_framework import (
AgentResponseUpdate,
WorkflowRunState,
)
from agent_framework.openai import OpenAIChatClient
@@ -48,7 +48,7 @@ async def run_autogen() -> None:
async def run_agent_framework() -> None:
"""Agent Framework's as_tool() for hierarchical agents with streaming."""
from agent_framework import FunctionCallContent, FunctionResultContent
from agent_framework import Content
from agent_framework.openai import OpenAIChatClient
client = OpenAIChatClient(model_id="gpt-4.1-mini")
@@ -78,7 +78,7 @@ async def run_agent_framework() -> None:
print("[Agent Framework]")
# Track accumulated function calls (they stream in incrementally)
accumulated_calls: dict[str, FunctionCallContent] = {}
accumulated_calls: dict[str, Content] = {}
async for chunk in coordinator.run("Create a tagline for a coffee shop", stream=True):
# Stream text tokens
@@ -88,7 +88,7 @@ async def run_agent_framework() -> None:
# Process streaming function calls and results
if chunk.contents:
for content in chunk.contents:
if isinstance(content, FunctionCallContent):
if content.type == "function_call":
# Accumulate function call content as it streams in
call_id = content.call_id
if call_id in accumulated_calls:
@@ -105,7 +105,7 @@ async def run_agent_framework() -> None:
current_args = accumulated_calls[call_id].arguments
print(f" Arguments: {current_args}", flush=True)
elif isinstance(content, FunctionResultContent):
elif content.type == "function_result":
# Tool result - shows writer's response
result_text = content.result if isinstance(content.result, str) else str(content.result)
if result_text.strip():