Skip to content

Commit ff0fade

Browse files
committed
OpenResponses support + cont work on agents
1 parent a8d51a5 commit ff0fade

File tree

385 files changed

+11848
-1698
lines changed

Some content is hidden

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

385 files changed

+11848
-1698
lines changed

config/llm.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,20 @@
239239
'contextLength' => 1_000_000,
240240
'maxOutputLength' => 16384,
241241
],
242+
'openai-responses' => [
243+
'driver' => 'openai-responses',
244+
'apiUrl' => 'https://api.openai.com/v1',
245+
'apiKey' => Env::get('OPENAI_API_KEY', ''),
246+
'endpoint' => '/responses',
247+
'metadata' => [
248+
'organization' => '',
249+
'project' => '',
250+
],
251+
'model' => 'gpt-4.1-nano',
252+
'maxTokens' => 1024,
253+
'contextLength' => 1_000_000,
254+
'maxOutputLength' => 16384,
255+
],
242256
'openrouter' => [
243257
'driver' => 'openrouter',
244258
'apiUrl' => 'https://openrouter.ai/api/v1',

docs-build/packages/addons/agent_hooks.mdx

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ $agent = AgentBuilder::new()
4444
})
4545

4646
->build();
47-
// @doctest id="f5ae"
47+
// @doctest id="0399"
4848
```
4949

5050
## Lifecycle Events
@@ -104,7 +104,7 @@ HookOutcome::block('Dangerous command detected');
104104

105105
// Stop the entire agent execution
106106
HookOutcome::stop('Budget exceeded');
107-
// @doctest id="5d31"
107+
// @doctest id="ec5c"
108108
```
109109

110110
### Semantic Differences
@@ -146,7 +146,7 @@ function afterTool(ToolHookContext $ctx): HookOutcome {
146146

147147
return HookOutcome::proceed();
148148
}
149-
// @doctest id="b09b"
149+
// @doctest id="5324"
150150
```
151151

152152
### StepHookContext
@@ -167,7 +167,7 @@ function onStep(StepHookContext $ctx): HookOutcome {
167167

168168
return HookOutcome::proceed();
169169
}
170-
// @doctest id="1454"
170+
// @doctest id="7e81"
171171
```
172172

173173
### StopHookContext
@@ -187,7 +187,7 @@ function onStop(StopHookContext $ctx): HookOutcome {
187187

188188
return HookOutcome::proceed(); // Allow stop
189189
}
190-
// @doctest id="e62a"
190+
// @doctest id="482f"
191191
```
192192

193193
### ExecutionHookContext
@@ -206,7 +206,7 @@ function onExecution(ExecutionHookContext $ctx): HookOutcome {
206206

207207
return HookOutcome::proceed();
208208
}
209-
// @doctest id="c416"
209+
// @doctest id="8e05"
210210
```
211211

212212
### FailureHookContext
@@ -223,7 +223,7 @@ function onFailure(FailureHookContext $ctx): HookOutcome {
223223

224224
return HookOutcome::proceed();
225225
}
226-
// @doctest id="b901"
226+
// @doctest id="ea9a"
227227
```
228228

229229
## Matchers
@@ -247,7 +247,7 @@ new ToolNameMatcher('*'); // Match all
247247

248248
// Regex patterns
249249
new ToolNameMatcher('/^(read|write)_.+$/');
250-
// @doctest id="2971"
250+
// @doctest id="9f59"
251251
```
252252

253253
### EventTypeMatcher
@@ -263,7 +263,7 @@ new EventTypeMatcher(HookEvent::PreToolUse);
263263

264264
// Multiple events
265265
new EventTypeMatcher(HookEvent::BeforeStep, HookEvent::AfterStep);
266-
// @doctest id="60f5"
266+
// @doctest id="2c61"
267267
```
268268

269269
### CompositeMatcher
@@ -294,7 +294,7 @@ $matcher = CompositeMatcher::and(
294294
),
295295
new CallableMatcher(fn($ctx) => $ctx->state()->metadata()->get('safe_mode')),
296296
);
297-
// @doctest id="b7d0"
297+
// @doctest id="d1ae"
298298
```
299299

300300
### CallableMatcher
@@ -307,7 +307,7 @@ use Cognesy\Addons\Agent\Hooks\Matchers\CallableMatcher;
307307
$matcher = new CallableMatcher(function (HookContext $ctx): bool {
308308
return $ctx->state()->metadata()->get('priority') === 'high';
309309
});
310-
// @doctest id="ec37"
310+
// @doctest id="d275"
311311
```
312312

313313
## Priority
@@ -324,7 +324,7 @@ $builder
324324

325325
// Logging hooks run last (low priority)
326326
->onAfterToolUse($logger, priority: -100);
327-
// @doctest id="994f"
327+
// @doctest id="3e91"
328328
```
329329

330330
**Priority Guidelines:**
@@ -352,7 +352,7 @@ $builder->onAfterToolUse(
352352
priority: int = 0,
353353
matcher: string|HookMatcher|null = null,
354354
);
355-
// @doctest id="0a6c"
355+
// @doctest id="6227"
356356
```
357357

358358
### Step Hooks
@@ -367,7 +367,7 @@ $builder->onBeforeStep(
367367
$builder->onAfterStep(
368368
callback: callable, // (AgentState) -> AgentState
369369
);
370-
// @doctest id="8036"
370+
// @doctest id="c1ae"
371371
```
372372

373373
### Execution Hooks
@@ -384,7 +384,7 @@ $builder->onExecutionEnd(
384384
callback: callable, // (ExecutionHookContext) -> HookOutcome|void
385385
priority: int = 0,
386386
);
387-
// @doctest id="48ea"
387+
// @doctest id="fcc9"
388388
```
389389

390390
### Continuation Hooks
@@ -401,7 +401,7 @@ $builder->onSubagentStop(
401401
callback: callable, // (StopHookContext) -> HookOutcome|void
402402
priority: int = 0,
403403
);
404-
// @doctest id="b48a"
404+
// @doctest id="6f4c"
405405
```
406406

407407
### Error Hooks
@@ -412,7 +412,7 @@ $builder->onAgentFailed(
412412
callback: callable, // (FailureHookContext) -> HookOutcome|void
413413
priority: int = 0,
414414
);
415-
// @doctest id="c6c3"
415+
// @doctest id="277b"
416416
```
417417

418418
### Unified Registration
@@ -428,7 +428,7 @@ $builder->addHook(
428428
hook: new CallableHook($callback, $matcher),
429429
priority: 100,
430430
);
431-
// @doctest id="2b8f"
431+
// @doctest id="00a3"
432432
```
433433

434434
## Creating Custom Hooks
@@ -457,7 +457,7 @@ class RateLimitHook implements Hook
457457
return $next($context);
458458
}
459459
}
460-
// @doctest id="c5af"
460+
// @doctest id="66b6"
461461
```
462462

463463
## Using HookStack Directly
@@ -482,7 +482,7 @@ if ($outcome->isBlocked()) {
482482
} elseif ($outcome->isStopped()) {
483483
// Handle stopped
484484
}
485-
// @doctest id="69df"
485+
// @doctest id="f4b9"
486486
```
487487

488488
## Backward Compatibility
@@ -498,7 +498,7 @@ use Cognesy\Addons\Agent\Hooks\Adapters\StateProcessorAdapter;
498498

499499
$processor = new YourStateProcessor();
500500
$hook = new StateProcessorAdapter($processor, position: 'after');
501-
// @doctest id="10d9"
501+
// @doctest id="4f94"
502502
```
503503

504504
### ContinuationCriteriaAdapter
@@ -508,7 +508,7 @@ use Cognesy\Addons\Agent\Hooks\Adapters\ContinuationCriteriaAdapter;
508508

509509
$criterion = new YourContinuationCriterion();
510510
$hook = new ContinuationCriteriaAdapter($criterion);
511-
// @doctest id="0c97"
511+
// @doctest id="0318"
512512
```
513513

514514
## Common Patterns
@@ -533,7 +533,7 @@ $builder->onBeforeToolUse(
533533
priority: 100, // Run first
534534
matcher: 'bash',
535535
);
536-
// @doctest id="9252"
536+
// @doctest id="5086"
537537
```
538538

539539
### Execution Timing
@@ -550,7 +550,7 @@ $builder
550550
$duration = microtime(true) - $started;
551551
$this->metrics->record('execution_duration', $duration);
552552
});
553-
// @doctest id="bce5"
553+
// @doctest id="4847"
554554
```
555555

556556
### Conditional Continuation
@@ -573,7 +573,7 @@ $builder->onStop(function (StopHookContext $ctx): HookOutcome {
573573

574574
return HookOutcome::proceed();
575575
});
576-
// @doctest id="b9bc"
576+
// @doctest id="8f96"
577577
```
578578

579579
### Error Recovery Logging
@@ -599,7 +599,7 @@ $builder->onAgentFailed(function (FailureHookContext $ctx): void {
599599
$this->alerting->sendCritical($exception);
600600
}
601601
});
602-
// @doctest id="95f0"
602+
// @doctest id="2b2b"
603603
```
604604

605605
## Architecture
@@ -631,7 +631,7 @@ $builder->onAgentFailed(function (FailureHookContext $ctx): void {
631631
│ │ execution│ │ action │ │ entirely │ │
632632
│ └──────────┘ └──────────┘ └──────────┘ │
633633
└─────────────────────────────────────────────────────────────┘
634-
// @doctest id="336c"
634+
// @doctest id="fda3"
635635
```
636636

637637
## File Structure
@@ -672,5 +672,5 @@ packages/addons/src/Agent/Hooks/
672672
└── Adapters/
673673
├── StateProcessorAdapter.php
674674
└── ContinuationCriteriaAdapter.php
675-
// @doctest id="e8b7"
675+
// @doctest id="c407"
676676
```

docs-build/packages/http/1-overview.mdx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ HttpClient
9494
└── withRequest() - Create pending request for execution
9595
└── pool() - Execute multiple requests concurrently
9696
└── withPool() - Create pending pool for deferred execution
97-
// @doctest id="5ab7"
97+
// @doctest id="b2a6"
9898
```
9999

100100
### Middleware Layer
@@ -105,7 +105,7 @@ The middleware system allows for processing requests and responses through a cha
105105
Request -> Middleware 1 -> Middleware 2 -> ... -> Driver -> External API
106106
107107
Response <- Middleware 1 <- Middleware 2 <- ... <- Driver <- HTTP Response
108-
// @doctest id="e1cb"
108+
// @doctest id="8181"
109109
```
110110

111111
Key components:
@@ -123,7 +123,7 @@ CanHandleHttpRequest (interface)
123123
├── SymfonyDriver
124124
├── LaravelDriver
125125
└── MockHttpDriver (for testing)
126-
// @doctest id="241a"
126+
// @doctest id="b739"
127127
```
128128

129129
### Adapter Layer
@@ -136,7 +136,7 @@ HttpResponse (interface)
136136
├── SymfonyHttpResponse
137137
├── LaravelHttpResponse
138138
└── MockHttpResponse
139-
// @doctest id="39df"
139+
// @doctest id="8873"
140140
```
141141

142142
## Supported HTTP Clients

0 commit comments

Comments
 (0)