Repository navigation
Improve the extension example: distinguish returned, raised and cancelled tool calls #6383
Replies: 2 comments
|
This looks like a useful, well-scoped example improvement. I support a PR limited to the example implementation, its offline tests, and README; the existing extension hooks appear sufficient. The reported gap is reproducible. In a focused local exercise through the host's The proposal already makes the right distinction between a normal return and business success. A few acceptance criteria would make the reference especially useful:
One existing test-fixture issue surfaced separately: No architectural blocker found for the proposed scope. |
|
Thanks for checking this and supporting the scope. I'll keep the PR limited |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
For extension authors building tool monitoring, the current example demonstrates counting calls, but not how to observe their outcomes and elapsed time while preserving execution behavior. I propose extending that same example and its existing
/api/extension-example/statsresponse.Concrete gap
At 53df22bd, the async tool wrapper increments
tool_callsbefore awaiting the handler. After task finalization, the count alone cannot distinguish three normal returns from one return, one raised exception and one cancellation. The example also has no sync observation wrapper.Illustrative outcome for three calls taking 10, 20 and 30 ms respectively — proposed output, not a measured result:
This would give extension authors a tested reference for preserving results and cancellation while collecting statistics, using existing public hooks without a telemetry service or new dependencies. It relates to the monitoring use case in #4357.
One bounded PR
TOOL_VISIBLEboundary; call the handler exactly once and preserve its result or exception.returnedincludes error messages returned normally, so it does not mean business success.raisedcounts exceptions escaping this wrapper.Tests would use a fake clock and synthetic handlers to cover returns (including returned error messages), exceptions, cancellation, zero duration, concurrent calls, missing task scope and aggregation without double-counting. Disabled behavior and existing endpoint fields would remain covered.
No core runtime, public contract, persistence or UI changes are proposed.
Would you welcome a PR limited to this example, its tests and README? I have not started implementation.
All reactions