Class: Protege::ReadAttachmentTool
- Inherits:
-
Tool
- Object
- Tool
- Protege::ReadAttachmentTool
- Defined in:
- app/tools/protege/read_attachment_tool.rb
Overview
Built-in tool that reads a stored file by its blob id. Subclasses Protege::Tool, so the harness
publishes it in the LLM's tool catalog (id :read_attachment).
The agent learns a file's blob id from the +ThreadHistoryResolver+/inbound note ("…, id: 123") or
from create_file. Resolution is by blob id (see Protege::StoredFile.find); persona scoping is
deferred to a later pass (see the blob-currency spec §9), so any known blob id currently resolves.
Behaviour by type:
- text-like (text/*, json, xml, csv) → the text content is returned in the result.
- image / PDF → returned as a "review" marker carrying only the blob id (no bytes); the harness rebuilds it as a vision part and injects it on the next user turn, because OpenAI-schema tool results can't carry images. The model then sees the actual image/PDF.
- anything else (video, archives) → a failure; it can't be read.
Instance Method Summary collapse
-
#use(context:, blob_id:) ⇒ Protege::Result
Resolve the file by blob id and read it according to its type.
Instance Method Details
#use(context:, blob_id:) ⇒ Protege::Result
Resolve the file by blob id and read it according to its type.
43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'app/tools/protege/read_attachment_tool.rb', line 43 def use(context:, blob_id:) file = Protege::StoredFile.find(blob_id) return missing_failure(blob_id) unless file if file.text? text_result(file) elsif file.viewable? review_result(file) else unviewable_failure(file) end end |