Skip to content

[0.x] Add timeout parameter to Agent contract#412

Merged
taylorotwell merged 1 commit intolaravel:0.xfrom
Tiagospem:add-timeout-parameter-to-agent-contract
Apr 21, 2026
Merged

[0.x] Add timeout parameter to Agent contract#412
taylorotwell merged 1 commit intolaravel:0.xfrom
Tiagospem:add-timeout-parameter-to-agent-contract

Conversation

@Tiagospem
Copy link
Copy Markdown

Add timeout parameter to Agent contract

The Promptable trait already accepts an optional ?int $timeout parameter on prompt() and stream(), but the Agent contract does not declare it. This causes IDE and static analysis warnings (e.g. PHPStan argument.named) when calling ->prompt(..., timeout: 120) on an Agent-typed variable, since the contract signature doesn't include the parameter.

Changes

  • Added ?int $timeout = null to Agent::prompt() and Agent::stream() in src/Contracts/Agent.php.

Why

The Promptable trait (used by all concrete agents) already supports timeout on both methods and passes it through to AgentPrompt. The contract simply didn't reflect this, creating a mismatch between the interface and its implementation.

Impact

  • Non-breaking: the parameter is optional with a null default.
  • Existing tests pass: the 4 timeout-related tests in AgentFakeTest already exercise timeout: as a named argument on both prompt() and stream().

@taylorotwell taylorotwell merged commit 69073a0 into laravel:0.x Apr 21, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants