Files
agent-framework/python/samples/02-agents/harness
T
Eduard van Valkenburg 8091d052d8 Python: refresh dev dependencies and validate runtime bounds (#6238)
Updates third-party dev dependencies across the Python workspace and
validates that all runtime dependency bounds still hold at both ends.

Dev dependency bumps (root, lab, declarative, durabletask):
- uv 0.11.6 -> 0.11.17, ruff 0.15.8 -> 0.15.15,
  pytest-asyncio 1.3.0 -> 1.4.0, mcp 1.27.0 -> 1.27.2,
  azure-monitor-opentelemetry 1.8.7 -> 1.8.8,
  poethepoet 0.42.1 -> 0.46.0, prek 0.3.9 -> 0.4.3,
  types-python-dateutil and types-PyYaml stub bumps.
- Transitive Dependabot items swept via lock: idna 3.11 -> 3.17,
  pip 26.0.1 -> 26.1.2.

Deliberately excluded:
- opentelemetry-sdk stays 1.40.0: azure-monitor-opentelemetry (incl.
  1.8.8) hard-pins opentelemetry-sdk==1.40.
- mypy stays 1.20.0 and pyright stays 1.1.408: the 2.1.0 / 1.1.409
  bumps introduce new diagnostics that fail type checking and need
  dedicated PRs.
- rich kept as a range: agentlightning (lab[lightning]) forces
  rich==13.9.4.

Code/formatting changes driven by the ruff upgrade:
- devui lifespan now uses try/finally so shutdown cleanup always runs
  (ruff RUF075).
- Removed unused TYPE_CHECKING imports in core and foundry flagged by
  ruff 0.15.15.
- Reapplied ruff 0.15.15 formatting to the files it changed.

Validation: validate-dependency-bounds-test "*" passes (31/31 lower +
31/31 upper); typing 62/62; lint 31/31; devui tests pass.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
8091d052d8 ยท 2026-06-01 17:53:56 +00:00
History
..

Harness Agent Samples

This folder demonstrates create_harness_agent โ€” a factory function that builds a pre-configured, batteries-included agent by assembling the full agent pipeline from a chat client.

What is create_harness_agent?

create_harness_agent bundles the following features into a single Agent instance:

Feature Description
Function invocation Automatic tool calling loop
Per-service-call persistence History persisted after every model call
Compaction Context-window management (sliding window + tool result compaction)
TodoProvider Todo list management for planning and tracking
AgentModeProvider Plan/execute mode tracking
MemoryContextProvider File-based durable memory (when memory_store provided)
SkillsProvider File-based skill discovery and progressive loading
OpenTelemetry Built-in observability

Each feature can be disabled or customized via keyword arguments.

Samples

File Description
harness_research.py Interactive research assistant with web search and planning workflow

Running

# Set your Foundry environment variables
export FOUNDRY_PROJECT_ENDPOINT="https://your-project.services.ai.azure.com/api/projects/your-project-name"
export FOUNDRY_MODEL="your-model-deployment-name"

# Authenticate with Azure (required for AzureCliCredential)
az login

# Run the research sample
python samples/02-agents/harness/harness_research.py

Key Concepts

Minimal Setup

create_harness_agent requires only a chat client and token budget parameters:

from agent_framework import create_harness_agent
from agent_framework.foundry import FoundryChatClient
from azure.identity import AzureCliCredential

agent = create_harness_agent(
    client=FoundryChatClient(credential=AzureCliCredential()),
    max_context_window_tokens=128_000,
    max_output_tokens=16_384,
)

Customization

Disable or customize any feature:

agent = create_harness_agent(
    client=client,
    max_context_window_tokens=128_000,
    max_output_tokens=16_384,
    name="my-agent",
    agent_instructions="Custom instructions here.",
    disable_todo=True,          # Skip todo management
    disable_mode=True,          # Skip plan/execute modes
    disable_compaction=True,    # Skip compaction
)

Plan/Execute Workflow

The AgentModeProvider enables a two-phase workflow:

  1. Plan mode โ€” Interactive: the agent asks questions, creates todos, gets approval
  2. Execute mode โ€” Autonomous: the agent works through todos independently