Skip to content

Commit b876156

Browse files
committed
minor #728 [Agent] Hardening & Slim down of Agent (chr-hertel)
This PR was merged into the main branch. Discussion ---------- [Agent] Hardening & Slim down of Agent | Q | A | ------------- | --- | Bug fix? | no | New feature? | no | Docs? | no | Issues | | License | MIT Basically hardening the agent by * getting rid of public properties in favor of getter/setter * removing unnecessary error handling * removing capability checks Commits ------- 5940dcd Slim down Agent by skipping unnecessary validations and exception handling + introduce getter/setter
2 parents 6209d9b + 5940dcd commit b876156

File tree

99 files changed

+294
-613
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

99 files changed

+294
-613
lines changed

examples/aimlapi/toolcall.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
$wikipedia = new Wikipedia(http_client());
2525
$toolbox = new Toolbox([$wikipedia], logger: logger());
2626
$processor = new AgentProcessor($toolbox);
27-
$agent = new Agent($platform, 'google/gemini-2.5-flash', [$processor], [$processor], logger: logger());
27+
$agent = new Agent($platform, 'google/gemini-2.5-flash', [$processor], [$processor]);
2828

2929
$messages = new MessageBag(Message::ofUser('Who is the current chancellor of Germany?'));
3030
$result = $agent->call($messages);

examples/anthropic/token-metadata.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
$platform = PlatformFactory::create(env('ANTHROPIC_API_KEY'), http_client());
2121

22-
$agent = new Agent($platform, 'claude-3-5-sonnet-20241022', outputProcessors: [new TokenOutputProcessor()], logger: logger());
22+
$agent = new Agent($platform, 'claude-3-5-sonnet-20241022', outputProcessors: [new TokenOutputProcessor()]);
2323
$messages = new MessageBag(
2424
Message::forSystem('You are a pirate and you write funny.'),
2525
Message::ofUser('What is the Symfony framework?'),

examples/anthropic/toolcall.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
$wikipedia = new Wikipedia(http_client());
2525
$toolbox = new Toolbox([$wikipedia], logger: logger());
2626
$processor = new AgentProcessor($toolbox);
27-
$agent = new Agent($platform, 'claude-3-5-sonnet-20241022', [$processor], [$processor], logger: logger());
27+
$agent = new Agent($platform, 'claude-3-5-sonnet-20241022', [$processor], [$processor]);
2828

2929
$messages = new MessageBag(Message::ofUser('Who is the current chancellor of Germany?'));
3030
$result = $agent->call($messages);

examples/bedrock/toolcall-claude.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
$wikipedia = new Wikipedia(http_client());
3131
$toolbox = new Toolbox([$wikipedia]);
3232
$processor = new AgentProcessor($toolbox);
33-
$agent = new Agent($platform, 'claude-3-7-sonnet-20250219', [$processor], [$processor], logger: logger());
33+
$agent = new Agent($platform, 'claude-3-7-sonnet-20250219', [$processor], [$processor]);
3434

3535
$messages = new MessageBag(Message::ofUser('Who is the current chancellor of Germany?'));
3636
$result = $agent->call($messages);

examples/bedrock/toolcall-nova.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
$wikipedia = new Wikipedia(http_client());
3131
$toolbox = new Toolbox([$wikipedia]);
3232
$processor = new AgentProcessor($toolbox);
33-
$agent = new Agent($platform, 'nova-pro', [$processor], [$processor], logger: logger());
33+
$agent = new Agent($platform, 'nova-pro', [$processor], [$processor]);
3434

3535
$messages = new MessageBag(
3636
Message::ofUser('Who is the current chancellor of Germany? Use Wikipedia to find the answer.')

examples/chat/persistent-chat.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
$platform = PlatformFactory::create(env('OPENAI_API_KEY'), http_client());
2222

23-
$agent = new Agent($platform, 'gpt-4o-mini', logger: logger());
23+
$agent = new Agent($platform, 'gpt-4o-mini');
2424
$chat = new Chat($agent, new InMemoryStore());
2525

2626
$messages = new MessageBag(

examples/dockermodelrunner/chat.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
$platform = PlatformFactory::create(env('DOCKER_MODEL_RUNNER_HOST_URL'), http_client());
2020

21-
$agent = new Agent($platform, 'ai/gemma3n', logger: logger());
21+
$agent = new Agent($platform, 'ai/gemma3n');
2222
$messages = new MessageBag(
2323
Message::forSystem('You are a pirate and you write funny.'),
2424
Message::ofUser('What is the Symfony framework?'),

examples/dockermodelrunner/toolcall.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
$wikipedia = new Wikipedia(http_client());
2525
$toolbox = new Toolbox([$wikipedia]);
2626
$processor = new AgentProcessor($toolbox);
27-
$agent = new Agent($platform, 'ai/gemma3n', [$processor], [$processor], logger: logger());
27+
$agent = new Agent($platform, 'ai/gemma3n', [$processor], [$processor]);
2828

2929
$messages = new MessageBag(Message::ofUser('Who is the actual Prime Minister of France?'));
3030
$result = $agent->call($messages);

examples/gemini/server-tools.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
$toolbox = new Toolbox([new Clock()], logger: logger());
2525
$processor = new AgentProcessor($toolbox);
26-
$agent = new Agent($platform, 'gemini-2.5-pro-preview-03-25', [$processor], [$processor], logger: logger());
26+
$agent = new Agent($platform, 'gemini-2.5-pro-preview-03-25', [$processor], [$processor]);
2727

2828
$messages = new MessageBag(
2929
Message::ofUser(

examples/gemini/structured-output-clock.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
$toolbox = new Toolbox([$clock]);
2828
$toolProcessor = new ToolProcessor($toolbox);
2929
$structuredOutputProcessor = new StructuredOutputProcessor();
30-
$agent = new Agent($platform, 'gemini-1.5-flash', [$toolProcessor, $structuredOutputProcessor], [$toolProcessor, $structuredOutputProcessor], logger: logger());
30+
$agent = new Agent($platform, 'gemini-1.5-flash', [$toolProcessor, $structuredOutputProcessor], [$toolProcessor, $structuredOutputProcessor]);
3131

3232
$messages = new MessageBag(Message::ofUser('What date and time is it?'));
3333
$result = $agent->call($messages, ['response_format' => [

0 commit comments

Comments
 (0)