-
Notifications
You must be signed in to change notification settings - Fork 34
Centralize jq payload preview size configuration #1066
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -7,7 +7,7 @@ This middleware package implements the jqschema functionality from the gh-aw sha | |||||
| - **Automatic JSON Schema Inference**: Uses the jq schema transformation logic to automatically infer the structure and types of JSON responses | ||||||
| - **Payload Storage**: Stores complete response payloads in `/tmp/gh-awmg/tools-calls/{randomID}/payload.json` | ||||||
| - **Response Rewriting**: Returns a transformed response containing: | ||||||
| - First 500 characters of the payload (for quick preview) | ||||||
| - First `PayloadPreviewSize` (500) characters of the payload (for quick preview) | ||||||
|
||||||
| - First `PayloadPreviewSize` (500) characters of the payload (for quick preview) | |
| - First `PayloadPreviewSize` bytes of the payload (default 500, for quick preview) |
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -22,6 +22,10 @@ var logMiddleware = logger.New("middleware:jqschema") | |||||||||
| // This prevents malformed queries or large payloads from causing hangs | ||||||||||
| const DefaultJqTimeout = 5 * time.Second | ||||||||||
|
|
||||||||||
| // PayloadPreviewSize is the maximum number of characters to include in the payload preview | ||||||||||
| // This controls how much of the original payload is returned inline when a payload is stored to disk | ||||||||||
|
Comment on lines
+25
to
+26
|
||||||||||
| // PayloadPreviewSize is the maximum number of characters to include in the payload preview | |
| // This controls how much of the original payload is returned inline when a payload is stored to disk | |
| // PayloadPreviewSize is the maximum number of bytes to include in the payload preview | |
| // This controls how much of the original payload (in UTF-8 bytes) is returned inline when a payload is stored to disk |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -253,7 +253,7 @@ func TestWrapToolHandler_LongPayload(t *testing.T) { | |||||
|
|
||||||
| // Verify preview truncation in Content field | ||||||
| preview := contentMap["payloadPreview"].(string) | ||||||
| assert.LessOrEqual(t, len(preview), 503, "Preview should be truncated to ~500 chars + '...'") | ||||||
| assert.LessOrEqual(t, len(preview), PayloadPreviewSize+3, "Preview should be truncated to PayloadPreviewSize chars + '...'") | ||||||
|
||||||
| assert.LessOrEqual(t, len(preview), PayloadPreviewSize+3, "Preview should be truncated to PayloadPreviewSize chars + '...'") | |
| assert.LessOrEqual(t, len(preview), PayloadPreviewSize+3, "Preview should be truncated to PayloadPreviewSize bytes + '...'") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This documentation refers to
PayloadPreviewSizeas "chars". The code currently truncates previews by bytes (and slices strings by byte index), so this should be updated to "bytes" or the implementation should be changed to be rune/character-based.This issue also appears on line 408 of the same file.
See below for a potential fix: