Testing deterministic tools invoked by stochastic models

Testing agent workflows by prompting an actual LLM in continuous integration creates flaky, expensive test suites that fail randomly whenever model weights or temperatures fluctuate.

// Test the tool contract deterministically, not the model:
public function test_migration_tool_rejects_dropping_columns_without_contract_flag(): void
{
    $tool = new MigrationPlannerTool($this->schemaInspector);

    $this->expectException(UnsafeMigrationException::class);
    $tool->execute([
        'action' => 'drop_column',
        'table' => 'users',
        'column' => 'legacy_token'
    ]);
}

The correct testing strategy for agentic infrastructure is testing the tool’s input validation and execution boundaries in standard PHPUnit tests. If a tool refuses unsafe actions deterministically, stochastic model mistakes are rendered harmless.