updated agents api to handle text files on artifact retrieval#3091
updated agents api to handle text files on artifact retrieval#3091tim-inkeep merged 4 commits intomainfrom
Conversation
🦋 Changeset detectedLatest commit: 55b3948 The changes in this PR will be included in the next version bump. This PR includes changesets to release 10 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
TL;DR — When the Key changes
Summary | 6 files | 2 commits | base: Text document artifacts decoded inline instead of sent as base64
The detection uses the existing
|
|
TL;DR — When the Key changes
Summary | 6 files | 4 commits | base: Text artifact hydration in
|
There was a problem hiding this comment.
Good fix. Text-document artifacts (e.g. .txt, .md, .csv) were being delivered as type: 'file' base64 content parts, which downstream toModelOutput maps to file-data — a format many LLMs don't handle well. This PR detects text MIME types early and decodes them into type: 'text' <attached_file> blocks, with a clean fallback to the base64 path on decode failure.
The conversation-history.ts refactor is also an improvement: the old code only had decode-error handling on the blob-download branch, leaving the inline-bytes path unprotected. The new structure handles both sources uniformly.
Minor (non-blocking): Now that resolvedFilename exists at default-tools.ts:69, the binary fallback path at line 129 (...(filename ? { filename } : {})) still uses the raw blob-URI-derived filename (e.g. sha256-abc.txt) rather than resolvedFilename. Consider updating it for consistency — though this predates the PR and isn't a regression.
Claude Opus | 𝕏
| "@inkeep/agents-api": patch | ||
| --- | ||
|
|
||
| Patched attachments bug |
There was a problem hiding this comment.
The changeset message is vague — consider describing the actual fix so consumers understand what changed.
| Patched attachments bug | |
| Handle text-document artifacts (`text/plain`, `text/markdown`, etc.) as decoded text content parts instead of base64 file parts, improving LLM comprehension of attached text files |
There was a problem hiding this comment.
Approving — the core logic is sound and well-tested. The changeset message nit and resolvedFilename consistency note are non-blocking.
Claude Opus | 𝕏
There was a problem hiding this comment.
PR Review Summary
(2) Total Issues | Risk: Low
🟠⚠️ Major (1) 🟠⚠️
Inline Comments:
- 🟠 Major:
.changeset/brave-chefs-refuse.md:5Changeset message does not follow style guidelines
💭 Consider (0) 💭
No consider items.
🧹 While You're Here (1) 🧹
Inline Comments:
- 🧹 While You're Here:
default-tools.ts:129Fallback path uses blobUri-derived filename instead of user-provided filename (pre-existing inconsistency)
🕐 Pending Recommendations (0)
No pending items — first review.
💡 APPROVE WITH SUGGESTIONS
Summary: This PR properly fixes the text file artifact retrieval bug. The implementation is clean: a new buildDecodedTextAttachmentBlock() helper consolidates decoding + wrapping, error handling gracefully falls back to base64 file delivery when text decoding fails, and comprehensive test coverage validates the happy path, toModelOutput mapping, and fallback behavior. The only actionable item is improving the changeset message to follow the repo's changelog conventions. The pre-existing filename inconsistency is a nice-to-fix if you're already in this code.
Discarded (3)
| Location | Issue | Reason Discarded |
|---|---|---|
conversation-history.test.ts |
Missing test for decode failure in buildTextAttachmentPart | The error path is tested indirectly via text-document-attachments.test.ts which validates the helper throws correctly. Integration-level test is nice-to-have but not required since the try/catch is straightforward. |
Agent.test.ts:2034 |
Only tests control character errors, not invalid UTF-8 errors | Both error types trigger the same fallback via a generic catch block. Low risk since the catch is untyped. |
default-tools.ts:69 |
Missing test for filename fallback when data.filename is undefined | The nullish coalescing is simple logic. Existing tests verify the user-provided filename path works. |
Reviewers (3)
| Reviewer | Returned | Main Findings | Consider | While You're Here | Inline Comments | Pending Recs | Discarded |
|---|---|---|---|---|---|---|---|
pr-review-standards |
2 | 0 | 0 | 0 | 2 | 0 | 0 |
pr-review-tests |
3 | 0 | 0 | 0 | 0 | 0 | 3 |
pr-review-errors |
0 | 0 | 0 | 0 | 0 | 0 | 0 |
| Total | 5 | 0 | 0 | 0 | 2 | 0 | 3 |
Note: Error handling reviewer found all patterns to be well-implemented — errors are logged appropriately, fallbacks are reasonable, and test coverage validates the fallback path.
Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com>
Preview URLsUse these stable preview aliases for testing this PR:
These point to the same Vercel preview deployment as the bot comment, but they stay stable and easier to find. Raw Vercel deployment URLs
|
There was a problem hiding this comment.
PR Review Summary
(0) Total Issues | Risk: Low
Delta Review
This is a re-review scoped to changes since the previous automated review.
Prior feedback status:
| Prior Issue | Status |
|---|---|
| 🟠 Major: Changeset message style | ✅ Resolved — Commit 55b39481e updated the message to follow repo conventions |
| 🧹 While You're Here: Pre-existing filename inconsistency in fallback path | Still applicable (pre-existing, not a blocker) |
Changes since last review:
55b39481e— Fixed changeset message: "Fix text file artifacts being returned as base64-encoded file parts instead of decoded text content"45063b644— Merge from main (version bumps, unrelated changes not in PR scope)
No new issues introduced. The implementation remains clean with proper error handling and test coverage.
✅ APPROVE
Summary: All prior feedback has been addressed. The changeset message now follows the repo's style guidelines with a clear, action-verb-led description of the fix. The implementation is solid — the buildDecodedTextAttachmentBlock() helper cleanly handles text artifact decoding, error handling gracefully falls back to base64 delivery, and test coverage validates both happy paths and failure scenarios. Ship it! 🚀
Reviewers (1)
| Reviewer | Returned | Main Findings | Consider | While You're Here | Inline Comments | Pending Recs | Discarded |
|---|---|---|---|---|---|---|---|
orchestrator (delta) |
0 | 0 | 0 | 0 | 0 | 0 | 0 |
| Total | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
Note: Delta review — prior issues already covered in previous review run. No new code changes to evaluate.
Ito Test Report ✅12 test cases ran. 12 passed. All 12 test cases passed (0 failures), and the unified local verification found no confirmed production-code defects across the covered run-domain chat and attachment scenarios. Key findings were that valid text attachments worked end-to-end on both /run/api/chat and SSE /run/v1/chat/completions (including OpenAI-style file_data, CRLF normalization, artifact hydration, filename-optional inputs, explicit conversationId continuation, and 8-way parallel submissions with no 500s), while invalid or unsafe inputs were correctly blocked with controlled 400s and cross-app/origin auth mismatches were rejected with 403, with results interpreted in the context of dev-only local auth/provider fallback setup and the required model field on /run/v1/chat/completions. ✅ Passed (12)Commit: Tell us how we did: Give Ito Feedback |













No description provided.