Skip to content

Commit 5a813e9

Browse files
committed
minor #186 [Agent] Add missing @throws tags (and description) to interfaces (OskarStark)
This PR was squashed before being merged into the main branch. Discussion ---------- [Agent] Add missing ``@throws`` tags (and description) to interfaces | Q | A | ------------- | --- | Bug fix? | no | New feature? | no | Docs? | yes | Issues | -- | License | MIT Following the pattern from #184, this commit adds missing `@throws` documentation to interface methods that can throw exceptions. This improves developer experience and helps static analysis tools understand the expected behavior. cc `@VincentLanglet` Commits ------- 7036dad [Agent] Add missing ``@throws`` tags (and description) to interfaces
2 parents 36397dc + 7036dad commit 5a813e9

File tree

11 files changed

+25
-13
lines changed

11 files changed

+25
-13
lines changed

src/agent/src/Agent.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ public function __construct(
5656

5757
/**
5858
* @param array<string, mixed> $options
59+
*
60+
* @throws MissingModelSupportException When the model doesn't support audio or image inputs present in the messages
61+
* @throws InvalidArgumentException When the platform returns a client error (4xx) indicating invalid request parameters
62+
* @throws RuntimeException When the platform returns a server error (5xx) or network failure occurs
5963
*/
6064
public function call(MessageBagInterface $messages, array $options = []): ResultInterface
6165
{

src/agent/src/AgentInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ interface AgentInterface
2323
/**
2424
* @param array<string, mixed> $options
2525
*
26-
* @throws ExceptionInterface
26+
* @throws ExceptionInterface When the agent encounters an error (e.g., unsupported model capabilities, invalid arguments, network failures, or processor errors)
2727
*/
2828
public function call(MessageBagInterface $messages, array $options = []): ResultInterface;
2929
}

src/agent/src/ChatInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ interface ChatInterface
2121
public function initiate(MessageBagInterface $messages): void;
2222

2323
/**
24-
* @throws ExceptionInterface
24+
* @throws ExceptionInterface When the chat submission fails due to agent errors
2525
*/
2626
public function submit(UserMessage $message): AssistantMessage;
2727
}

src/agent/src/StructuredOutput/AgentProcessor.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ public function __construct(
4545
}
4646
}
4747

48+
/**
49+
* @throws MissingModelSupportException When structured output is requested but the model doesn't support it
50+
* @throws InvalidArgumentException When streaming is enabled with structured output (incompatible options)
51+
*/
4852
public function processInput(Input $input): void
4953
{
5054
$options = $input->getOptions();

src/agent/src/Toolbox/ToolCallArgumentResolver.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ public function __construct(
3838

3939
/**
4040
* @return array<string, mixed>
41+
*
42+
* @throws ToolException When a mandatory tool parameter is missing from the tool call arguments
4143
*/
4244
public function resolveArguments(Tool $metadata, ToolCall $toolCall): array
4345
{

src/mcp-sdk/src/Message/Factory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ final class Factory
1818
/**
1919
* @return iterable<Notification|Request|InvalidInputMessageException>
2020
*
21-
* @throws \JsonException
21+
* @throws \JsonException When the input string is not valid JSON
2222
*/
2323
public function create(string $input): iterable
2424
{

src/mcp-sdk/src/Server/JsonRpcHandler.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ public function __construct(
5454
/**
5555
* @return iterable<string|null>
5656
*
57-
* @throws ExceptionInterface
58-
* @throws \JsonException
57+
* @throws ExceptionInterface When a handler throws an exception during message processing
58+
* @throws \JsonException When JSON encoding of the response fails
5959
*/
6060
public function process(string $input): iterable
6161
{
@@ -103,7 +103,7 @@ public function process(string $input): iterable
103103
}
104104

105105
/**
106-
* @throws \JsonException
106+
* @throws \JsonException When JSON encoding fails
107107
*/
108108
private function encodeResponse(Response|Error|null $response): ?string
109109
{
@@ -123,7 +123,7 @@ private function encodeResponse(Response|Error|null $response): ?string
123123
}
124124

125125
/**
126-
* @throws ExceptionInterface
126+
* @throws ExceptionInterface When a notification handler throws an exception
127127
*/
128128
private function handleNotification(Notification $notification): null
129129
{
@@ -143,8 +143,8 @@ private function handleNotification(Notification $notification): null
143143
}
144144

145145
/**
146-
* @throws NotFoundExceptionInterface
147-
* @throws ExceptionInterface
146+
* @throws NotFoundExceptionInterface When no handler is found for the request method
147+
* @throws ExceptionInterface When a request handler throws an exception
148148
*/
149149
private function handleRequest(Request $request): Response|Error
150150
{

src/mcp-sdk/src/Server/NotificationHandlerInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ interface NotificationHandlerInterface
1919
public function supports(Notification $message): bool;
2020

2121
/**
22-
* @throws ExceptionInterface
22+
* @throws ExceptionInterface When the handler encounters an error processing the notification
2323
*/
2424
public function handle(Notification $notification): void;
2525
}

src/mcp-sdk/src/Server/RequestHandlerInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ interface RequestHandlerInterface
2121
public function supports(Request $message): bool;
2222

2323
/**
24-
* @throws ExceptionInterface
24+
* @throws ExceptionInterface When the handler encounters an error processing the request
2525
*/
2626
public function createResponse(Request $message): Response|Error;
2727
}

src/platform/src/Bridge/Gemini/Gemini/ModelClient.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public function supports(Model $model): bool
3939
}
4040

4141
/**
42-
* @throws TransportExceptionInterface
42+
* @throws TransportExceptionInterface When the HTTP request fails due to network issues
4343
*/
4444
public function request(Model $model, array|string $payload, array $options = []): RawHttpResult
4545
{

0 commit comments

Comments
 (0)