Python: Add a HarnessAgent with available features and sample#6041
Python: Add a HarnessAgent with available features and sample#6041westey-m wants to merge 12 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a new Python HarnessAgent convenience wrapper (with default context providers and compaction), introduces a context-window–based compaction strategy, and provides a sample demonstrating the bundled agent pipeline.
Changes:
- Introduce
HarnessAgent(experimental) that assembles history + compaction + todo/mode/memory/skills providers and optionally telemetry. - Add
ContextWindowCompactionStrategyplus tests covering threshold-triggered tool eviction and truncation. - Add a
HarnessAgentsample (README + interactive research loop) and minor formatting/import tweaks elsewhere.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| python/samples/02-agents/harness/README.md | Adds documentation for the HarnessAgent sample and feature overview. |
| python/samples/02-agents/harness/harness_research.py | Adds an interactive research assistant sample using HarnessAgent + Foundry web search. |
| python/packages/foundry_hosting/tests/test_responses.py | Minor whitespace adjustment in tests. |
| python/packages/foundry_hosting/agent_framework_foundry_hosting/_responses.py | Import cleanup/reordering. |
| python/packages/core/tests/core/test_harness_agent.py | Adds unit tests validating HarnessAgent assembly and options. |
| python/packages/core/tests/core/test_compaction.py | Adds unit tests for ContextWindowCompactionStrategy. |
| python/packages/core/agent_framework/_harness/_agent.py | Implements HarnessAgent plus assembly helpers and defaults. |
| python/packages/core/agent_framework/_compaction.py | Adds ContextWindowCompactionStrategy and exports it. |
| python/packages/core/agent_framework/init.py | Exports HarnessAgent, DEFAULT_HARNESS_INSTRUCTIONS, and ContextWindowCompactionStrategy. |
| .devcontainer/devcontainer.json | Updates the Python devcontainer image/features and adds VS Code extensions. |
There was a problem hiding this comment.
Automated Code Review
Reviewers: 4 | Confidence: 88%
✓ Correctness
The core logic of ContextWindowCompactionStrategy and HarnessAgent is correct. The TokenBudgetComposedStrategy properly re-annotates tokens between phases, and the two-phase compaction pipeline works as designed. The main new issue is a duplicate
from pathlib import Pathimport introduced in _responses.py, which is clearly a merge/editing artifact. The previously-flagged issues (_assemble_instructions empty-string fallback, sample docstring placement, test coverage for disable_memory, and test docstring/assertion mismatch) remain valid and unresolved.
✓ Security Reliability
No significant security or reliability issues found. The PR introduces proper input validation in both
ContextWindowCompactionStrategyandHarnessAgentconstructors, correctly bounds threshold parameters, and delegates to well-tested existing compaction infrastructure. The only concrete code issue is a duplicate import introduced in_responses.py, which is harmless at runtime but indicates an incomplete merge.
✓ Test Coverage
The PR adds a HarnessAgent class and ContextWindowCompactionStrategy with good assembly/construction test coverage, but the primary runtime API method
HarnessAgent.run()has zero test coverage. The existing tests verify assembly and configuration but never execute the agent's main behavior. Additionally,get_session()is untested and there is no test verifying that both compaction phases (tool eviction + truncation) fire together in a single call.
✓ Design Approach
The main design issue I found is in the new HarnessAgent sample: it instructs the model to save its final report to file memory, but the sample never configures a memory store, so the HarnessAgent assembly path never adds MemoryContextProvider. That leaves the sample advertising a capability it does not actually expose.
Automated review by westey-m's agents
Python Test Coverage Report •
Python Unit Test Overview
|
||||||||||||||||||||||||||||||||||||||||||||||||||
Co-authored-by: Eduard van Valkenburg <eavanvalkenburg@users.noreply.github.com>
Motivation and Context
#6034
Description
Contribution Checklist