Skip to content

Commit 174e1e9

Browse files
committed
minor #516 [Agent] Make $options parameter default to empty array in Input and Output (OskarStark)
This PR was squashed before being merged into the main branch. Discussion ---------- [Agent] Make `$options` parameter default to empty array in `Input` and `Output` | Q | A | ------------- | --- | Bug fix? | no | New feature? | yes | Docs? | no | Issues | -- | License | MIT Commits ------- dcb7f3a [Agent] Make `$options` parameter default to empty array in `Input` and `Output`
2 parents cbb466a + dcb7f3a commit 174e1e9

File tree

6 files changed

+15
-15
lines changed

6 files changed

+15
-15
lines changed

src/agent/src/Input.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ final class Input
2525
public function __construct(
2626
public Model $model,
2727
public MessageBag $messages,
28-
private array $options,
28+
private array $options = [],
2929
) {
3030
}
3131

src/agent/src/Output.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public function __construct(
2727
public readonly Model $model,
2828
public ResultInterface $result,
2929
public readonly MessageBag $messages,
30-
public readonly array $options,
30+
public readonly array $options = [],
3131
) {
3232
}
3333
}

src/agent/tests/InputProcessor/ModelOverrideInputProcessorTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public function testProcessInputWithValidModelOption()
4848
public function testProcessInputWithoutModelOption()
4949
{
5050
$gpt = new Gpt();
51-
$input = new Input($gpt, new MessageBag(), []);
51+
$input = new Input($gpt, new MessageBag());
5252

5353
$processor = new ModelOverrideInputProcessor();
5454
$processor->processInput($input);

src/agent/tests/InputProcessor/SystemPromptInputProcessorTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public function testProcessInputAddsSystemMessageWhenNoneExists()
4747
{
4848
$processor = new SystemPromptInputProcessor('This is a system prompt');
4949

50-
$input = new Input(new Gpt(), new MessageBag(Message::ofUser('This is a user message')), []);
50+
$input = new Input(new Gpt(), new MessageBag(Message::ofUser('This is a user message')));
5151
$processor->processInput($input);
5252

5353
$messages = $input->messages->getMessages();
@@ -65,7 +65,7 @@ public function testProcessInputDoesNotAddSystemMessageWhenOneExists()
6565
Message::forSystem('This is already a system prompt'),
6666
Message::ofUser('This is a user message'),
6767
);
68-
$input = new Input(new Gpt(), $messages, []);
68+
$input = new Input(new Gpt(), $messages);
6969
$processor->processInput($input);
7070

7171
$messages = $input->messages->getMessages();
@@ -92,7 +92,7 @@ public function execute(ToolCall $toolCall): mixed
9292
}
9393
);
9494

95-
$input = new Input(new Gpt(), new MessageBag(Message::ofUser('This is a user message')), []);
95+
$input = new Input(new Gpt(), new MessageBag(Message::ofUser('This is a user message')));
9696
$processor->processInput($input);
9797

9898
$messages = $input->messages->getMessages();
@@ -130,7 +130,7 @@ public function execute(ToolCall $toolCall): mixed
130130
}
131131
);
132132

133-
$input = new Input(new Gpt(), new MessageBag(Message::ofUser('This is a user message')), []);
133+
$input = new Input(new Gpt(), new MessageBag(Message::ofUser('This is a user message')));
134134
$processor->processInput($input);
135135

136136
$messages = $input->messages->getMessages();
@@ -170,7 +170,7 @@ public function execute(ToolCall $toolCall): mixed
170170
}
171171
);
172172

173-
$input = new Input(new Gpt(), new MessageBag(Message::ofUser('This is a user message')), []);
173+
$input = new Input(new Gpt(), new MessageBag(Message::ofUser('This is a user message')));
174174
$processor->processInput($input);
175175

176176
$messages = $input->messages->getMessages();

src/agent/tests/StructuredOutput/AgentProcessorTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public function testProcessInputWithoutOutputStructure()
5656
$processor = new AgentProcessor(new ConfigurableResponseFormatFactory());
5757

5858
$model = new Model('gpt-4', [Capability::OUTPUT_STRUCTURED]);
59-
$input = new Input($model, new MessageBag(), []);
59+
$input = new Input($model, new MessageBag());
6060

6161
$processor->processInput($input);
6262

@@ -162,7 +162,7 @@ public function testProcessOutputWithoutResponseFormat()
162162
$model = self::createMock(Model::class);
163163
$result = new TextResult('');
164164

165-
$output = new Output($model, $result, new MessageBag(), []);
165+
$output = new Output($model, $result, new MessageBag());
166166

167167
$processor->processOutput($output);
168168

src/agent/tests/Toolbox/AgentProcessorTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public function testProcessInputWithoutRegisteredToolsWillResultInNoOptionChange
4949

5050
$model = new Model('gpt-4', [Capability::TOOL_CALLING]);
5151
$processor = new AgentProcessor($toolbox);
52-
$input = new Input($model, new MessageBag(), []);
52+
$input = new Input($model, new MessageBag());
5353

5454
$processor->processInput($input);
5555

@@ -65,7 +65,7 @@ public function testProcessInputWithRegisteredToolsWillResultInOptionChange()
6565

6666
$model = new Model('gpt-4', [Capability::TOOL_CALLING]);
6767
$processor = new AgentProcessor($toolbox);
68-
$input = new Input($model, new MessageBag(), []);
68+
$input = new Input($model, new MessageBag());
6969

7070
$processor->processInput($input);
7171

@@ -94,7 +94,7 @@ public function testProcessInputWithUnsupportedToolCallingWillThrowException()
9494

9595
$model = new Model('gpt-3');
9696
$processor = new AgentProcessor($this->createStub(ToolboxInterface::class));
97-
$input = new Input($model, new MessageBag(), []);
97+
$input = new Input($model, new MessageBag());
9898

9999
$processor->processInput($input);
100100
}
@@ -115,7 +115,7 @@ public function testProcessOutputWithToolCallResponseKeepingMessages()
115115
$processor = new AgentProcessor($toolbox, keepToolMessages: true);
116116
$processor->setAgent($agent);
117117

118-
$output = new Output($model, $result, $messageBag, []);
118+
$output = new Output($model, $result, $messageBag);
119119

120120
$processor->processOutput($output);
121121

@@ -140,7 +140,7 @@ public function testProcessOutputWithToolCallResponseForgettingMessages()
140140
$processor = new AgentProcessor($toolbox, keepToolMessages: false);
141141
$processor->setAgent($agent);
142142

143-
$output = new Output($model, $result, $messageBag, []);
143+
$output = new Output($model, $result, $messageBag);
144144

145145
$processor->processOutput($output);
146146

0 commit comments

Comments
 (0)