Agent middleware
The composable unit of an agentic-coding-harness: a piece of scaffolding that hooks into the agent’s core loop at defined points and handles one concern, so a harness is assembled by stacking middleware rather than adopting a monolithic framework langchain-custom-harness.
The hook points
A base agent loop is just model → calls tools → repeat until done. Middleware can intervene before/after each model call, before/after each tool call, and at agent startup & teardown langchain-custom-harness. That gives the harness its real job — delivering the right context to the model at each step — a place to act.
Four levers
- Deterministic logic — business rules / dynamic control (do mechanical work in code, not tokens).
- Tool lifecycle — setup, teardown, registration.
- Custom state — tracking across the run (cf. durable-agents’ workflow-state separation).
- Stream handlers — transforming model/tool output.
Prebuilt examples (LangChain)
Context engineering (SummarizationMiddleware, ContextEditingMiddleware), memory
(MemoryMiddleware, cf. gbrain), environment (ShellToolMiddleware), delegation
(SubAgentMiddleware — the agent-orchestration fan-out as a drop-in), retries
(ToolRetryMiddleware), policy/governance (PIIMiddleware, HumanInTheLoopMiddleware — the
supervised-gate pattern of agent-kanban), and cost (PromptCachingMiddleware).
Why it matters
It’s the mechanism under the harness thesis. Where agentic-coding-harness says structure substitutes for capability, middleware names the structural primitive: small, single-concern, composable. It reframes harness-building as selecting and ordering middleware for the task — the engineering surface behind “task-harness fit > raw model capability” langchain-custom-harness. The named LangChain middleware also map cleanly onto concerns this wiki already tracks separately (orchestration, durability, supervision, skills/memory), suggesting the harness is a middleware stack over those threads.
Related
agentic-coding-harness · langchain-custom-harness · langchain · agent-orchestration · durable-agents · spec-driven-development