Repository navigation
feat(kiseno-slack-bot): pass Slack files to the agent - #256
Merged
Merged
Conversation
Files attached in Slack never reached the agent: the bot sent only the message text, so a question about an uploaded chart got an answer made up from the text alone. The bot now downloads attached files (scope files:read). Images go to the agent as A2A file parts and the runner hands them to the model as image_url parts; text files such as CSV become part of the prompt. Every file also gets a note on its message's line, so the model knows about files it cannot read.
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars.
|
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Files attached in Slack never reached the agent: the bot sent only the message text. A question about an uploaded chart got an answer made up from the text alone, because the model did not even know a file existed. With this change the bot downloads attached files, images reach the model as images, and text files become part of the prompt.
What the agent gets
image_urlpartstext/*(plain text, CSV, Markdown, code), JSON, YAML, XML[File name, attached by person]and[End of name]Every file gets a note on its message's line, for example
[image chart.png: attached after the conversation]or[file slides.pdf: PDF files cannot be read here], so the model can say it cannot open a file instead of guessing. Files from earlier messages in the thread (or the last 20 DM messages) count too, so follow-up questions about an image work; newer files win when a limit is reached.qwen3-8-27bcan see: it runsQwen/Qwen3.8-27B-FP8, whose config has a vision encoder, and the vLLM deployment does not turn it off. This PR does not prove that end to end; the first image in Slack does.Safety
https://*.slack.comURLs; other URLs are refused before any request. httpx drops the header on redirects to another host.files:read, Slack answers file URLs with its HTML sign-in page and status 200. The bot recognizes that, logs a warning that names the scope, and the file gets the note "could not be downloaded".Runner
input_images()takes PNG, JPEG, GIF and WebP file parts with bytes from the A2A message (at most 4) andrun_agentputs them after the text, each after a text partImage <name>:. The agent card lists those types as input modes. A test sends exactly the v0.3 JSON the bot sends to the runner's compat endpoint, and another one goes through the a2a-sdk client LiteLLM uses. LiteLLM itself converts v0.3 file parts with the same SDK (to_core_part: bytes becomerawwithmedia_typeandfilename).The first commit replaces the CRM tool names in the runner's README, docstrings and tests from #253 with neutral ones (
crm-find_events).Rollout
files:readunder OAuth & Permissions and reinstall the app. Until then files get the note "could not be downloaded", nothing breaks.Testing
python -m pytest -qpasses on Python 3.11 and 3.12:kiseno-slack-bot122 passed,kiseno-agent-runner51 passed. New tests cover reading images and text files, the image limit, thumbnails for large and HEIC images, the sign-in page, deleted and external files, cut text, text decoding (UTF-8, Windows-1252, a character cut at the end), where the fetcher sends the token, the full DM with a CSV and an image, a mention whose files are only on the fetched message, and the runner's image handling.