-
-
Notifications
You must be signed in to change notification settings - Fork 411
feat(agents): generator-as-protocol-adapter and tool coercion #2279
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
b80ef61
feat(agents): generator-as-protocol-adapter and tool coercion
723c08b
refactor(agents): replace mixin-based retry/rate-limiting with middle…
5b4199a
chore(agents): bump Python to 3.12+, fix tests for middleware API, ad…
0e25fe8
test(agents): restore sleep-time assertions in retry tests via asynci…
166601d
test(agents): tighten serialization test assertions per review feedback
198bdb9
Merge branch 'main' into feat/generator-middleware-pipeline
Hartorn 297665c
Merge remote-tracking branch 'origin/feat/generator-middleware-pipeli…
Hartorn 29a8240
refactor(agents): extract _call_model template method in BaseGenerator
Hartorn 3c5c709
Merge branch 'main' into feat/generator-middleware-pipeline
mattbit 2457430
refactor(agents): add built-in retry/rate-limiter slots with convenie…
Hartorn 5e69aed
Merge branch 'main' into feat/generator-middleware-pipeline
Hartorn 191dab6
Merge branch 'feat/generator-middleware-pipeline' of github.com:Giska…
Hartorn 8278eea
fix(agents): move param validation inside try block and add _call_mod…
Hartorn 7c87de0
Merge branch 'main' of github.com:Giskard-AI/giskard-oss into refacto…
Hartorn 4548a22
Merge branch 'main' into refactor/generator-as-protocol-adapter
mattbit e23c289
refactor(generators): move serialization into LiteLLMGenerator, add G…
Hartorn 74d7e80
fix(tests): resolve basedpyright warnings in test files
Hartorn File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| --- | ||
| description: Generator as protocol adapter — architectural rules for provider translation in giskard-agents. | ||
| alwaysApply: true | ||
| --- | ||
|
|
||
| # Generator as Protocol Adapter | ||
|
|
||
| ## Core Principles | ||
|
|
||
| 1. **Message is the canonical internal format.** `role="tool"`, `tool_call_id`, `tool_calls` are the project's standard fields. Never reshape `Message` to accommodate a specific provider. | ||
|
|
||
| 2. **Tool.run() returns `str`.** The tool serializes its own output. The workflow wraps the string into a `Message`. The workflow never calls `json.dumps` on tool results. | ||
|
|
||
| 3. **The generator owns all provider translation.** Each generator subclass is responsible for converting between internal `Message` objects and whatever wire format the provider expects. Serialization is internal to the subclass — `BaseGenerator` does not impose any wire format. | ||
|
|
||
| ## Rules | ||
|
|
||
| - **Do not call provider APIs (litellm, anthropic, openai, etc.) from workflow, tool, or chat code.** Provider calls belong exclusively in generator subclasses. | ||
| - **Do not import provider libraries outside of generator modules.** The `generators/` package is the only place that should depend on provider SDKs. | ||
| - **`_complete` is the template method.** It merges params via `GenerationParams.merge()`, calls the abstract `_call_model`, and wraps the result in a `Response`. Do not override `_complete` in production subclasses — override `_call_model` instead. | ||
| - **`_call_model` receives internal types.** Signature: `_call_model(messages: list[Message], params: GenerationParams) -> tuple[Message, FinishReason]`. The base class never touches wire formats. | ||
| - **Serialization is the subclass's concern.** Each subclass handles translating `Message`/`Tool` to its provider's wire format inside `_call_model` (e.g. `LiteLLMGenerator._serialize_messages`). Do not add serialization methods to `BaseGenerator`. | ||
| - **Param merging lives on `GenerationParams.merge()`.** Scalar fields from overrides replace the base; tools are concatenated. Do not reimplement merge logic elsewhere. | ||
| - **Adding a new provider?** Subclass `BaseGenerator` and implement `_call_model`. Handle all serialization/deserialization inside the subclass. Do not modify `Message`, `Tool`, or workflow code. | ||
| - **Cross-cutting concerns use middleware.** Retries, rate limiting, logging, and similar concerns are implemented as `CompletionMiddleware` subclasses, not generator mixins. See `generators/middleware.py`. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.