AI agents: harnesses, tools and MCP

AI agents: harnesses, tools and MCP

Учебные материалы

The model proposes; the application executes

A harness assembles context, validates and executes tool calls, returns results to the model, and stops execution. A tool call is a proposed function call with arguments. Nothing has happened until the application executes it.

ApproachWho selects the next stepExample
WorkflowA predefined route with branchesValidate invoice → extract fields → save
AgentThe model, using earlier action resultsInvestigate a failure and choose searches based on findings

ReAct (Reasoning + Acting) alternates reasoning, actions and observations: results received from the environment. An observation informs the next step. This does not require exposing hidden reasoning to the user or necessarily fine-tuning a model.

AI agents: harnesses, tools and MCP: mechanism diagram with an example

Checks before execution

  1. Purpose. A tool description explains when to use it, its inputs, outputs and external effects.
  2. Structure. A schema validates argument types and required fields.
  3. Permissions. The application checks the user's authority for the specific action and object.
  4. Confirmation. When human consent is required, validate it before the external action.

A string containing someone else's invoice identifier (ID) can pass schema validation and fail authorization. A proposed transfer({amount:1000}) does not itself authorize a transfer.

Example: find a report and email it

  1. The model requests search_report. The application executes an authorized search.
  2. The tool returns reportId: R17. This is an observation, not a model-invented ID.
  3. After recipient checks and required confirmation, the application calls the sending tool with R17.
  4. It verifies the actual sending result. The model saying “done” is insufficient.

Sending depends on retrieval, so these steps cannot run simultaneously. Two independent reads may run in parallel within service limits. If a tool is unavailable, revise the plan within existing permissions or report the limitation; imaginary calls execute nothing.

MCP: a common connection protocol

Model Context Protocol (MCP) standardizes communication between an application and external servers. The host coordinates the application and creates client connections. A client maintains communication with a particular server.

MCP capabilityMeaningExample
ToolsCallable actionsFind a report
ResourcesData addressed by URI (Uniform Resource Identifier)Document contents
PromptsReusable message templatesA report-analysis template with arguments

Connecting an MCP server does not grant permission to delete arbitrary files. Authorization remains a separate system responsibility.

Subagents and outcome checks

A subagent receives a bounded task: a goal, relevant data, constraints and a verifiable output format. Database-schema analysis needs the schema and requirements, usually not the main agent's secrets. Delegation is justified when its benefit outweighs extra latency and cost.

Agreement between two agents is not independent verification when both use the same faulty source. Check the changed file, record or operation result. An eval harness is a separate use of the word: infrastructure that runs evaluation tasks and collects metrics.