Skip to content

Repository files navigation

Microsoft Agent Framework QA Middleware

English · 简体中文 · 日本語 · Español · Português · 한국어

English cover for Microsoft Agent Framework QA Middleware

A middleware-style pipeline that authorizes, recognizes, redacts, and audits an owned visual QA fixture.

Introduction

CapSolver is wrapped behind a mock-first boundary in this reference implementation. This repository applies the official Microsoft Agent Framework extension surface to ordered middleware stages with redaction before the result reaches an agent. The example is intentionally limited to a generated visual checkpoint from an owned QA environment.

Features

  • Separates authorization, recognition, redaction, and audit into ordered stages.
  • Fails closed if a stage is invoked out of order.
  • Hashes provider task IDs before returning a result.
  • Emits a structured audit event without image data or credentials.
  • Runs offline with an injected fixture recognizer.

How It Works

A small context object moves through four middleware stages. Authorization records the approved scope, recognition calls the injected adapter, redaction minimizes the result, and audit records outcome and timestamp. Each stage asserts the state produced by its predecessor.

Only the recognition adapter knows the documented task payload; middleware carries a normalized result instead of the raw response. The field names and synchronous behavior are grounded in the official ImageToTextTask request and response contract and createTask operation.

Architecture

agent tool request -> authorization middleware -> OCR adapter -> redaction -> audit event

Microsoft Agent Framework exposes middleware and workflow patterns, making ordered cross-cutting controls a natural integration boundary.

Quick Start

python -m venv .venv
source .venv/bin/activate
pip install -e '.[framework]'
PYTHONPATH=src python -m unittest discover -s tests -v
PYTHONPATH=src python examples/basic_usage.py
PYTHONPATH=src python -c 'import maf_qa_middleware; print(maf_qa_middleware.__version__)'

The Microsoft Agent Framework quick start uses tests/fixtures/owned-qa.png; it does not load a browser session, API key, or external page.

Usage

Build the offline pipeline and pass an owned fixture plus its authorization reference:

result = run_middleware_pipeline(encoded_fixture, 'QA-MAF-12', FixtureRecognizer())

The runnable Microsoft Agent Framework example in examples/basic_usage.py remains fully offline. A live client cannot be constructed until the operator supplies CAPSOLVER_API_KEY locally and deliberately sets CAPSOLVER_ALLOW_LIVE=1. Store the key outside the repository and agent context; the adapter still expects an approved authorization reference.

Example Output

authorized=True
text=MAF-QA
audit.outcome=recognized

Project Structure

src/maf_qa_middleware/          core policy, client, tool, and workflow adapters
examples/           runnable mock-first demonstration
tests/unit/         rejection and configuration checks
tests/integration/  end-to-end flow with the bundled synthetic image
docs/               five localized README files
assets/cover.png    shared English repository cover

Testing

Run the full offline suite with:

PYTHONPATH=src python -m unittest tests.unit.test_config tests.integration.test_mock_flow.GraphFlowTests -v
python -m compileall -q src

Tests prove recognition cannot precede authorization and verify that the final audit event excludes encoded image data. No test instantiates an LLM, opens a browser, contacts the recognition endpoint, or reads a real credential.

Troubleshooting

  • Preserve middleware order.
  • Inspect the normalized context rather than the raw adapter response.
  • Store audit events with a defined retention period.

Responsible Use

Limit middleware input to approved fixtures, minimize audit fields, define retention and access controls, and never use the pipeline against restricted pages, private records, or third-party accounts. Stop immediately when authorization is withdrawn or the observed scope differs from the approved test plan.

Contributing

Read CONTRIBUTING.md before changing the Microsoft Agent Framework adapter. Contributions must keep mock-first tests, explicit authorization, and bounded live execution.

Security

Follow SECURITY.md when reporting an issue in the Microsoft Agent Framework integration. Treat image payloads, task identifiers, agent traces, and browser sessions as potentially sensitive even when the fixture is synthetic.

Conclusion

The pipeline turns authorization and redaction into explicit middleware stages instead of informal agent instructions, while the recognition contract stays aligned with CapSolver.

Disclosure

Developer sharing CapSolver integration examples.

License

MIT. See LICENSE.

About

Microsoft Agent Framework middleware boundary for audited CapSolver visual QA tasks.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages