cloudflare / cloudflare/cloudflare-os
Attached resources reach the agent as just a name, burning tokens
- Dominant language
- TypeScript
- Stars
- 9.9k
- Forks
- 1.2k
- Avg merge
- 1d 20h
- Merged PRs (30d)
- 107
Description
When I attach a resource, the agent gets a `env` name, not the resource details. The `msg.capsules` branch in `runAgent` rewrites it to `[Title](env.NAME)` inline in my message and that's the whole signal — no type, no API, nothing.
So it guesses. Here's a turn where I attached two resources:
> They provide env bindings: BOBA_TOONS_OS (GitHub?) and CLOUDFLARE_API_KEY.
`(GitHub?)` — it's holding a live handle to that repo and guessing what it is, then planning around the names instead of calling `describeBinding`.
The other two ways a resource lands in `env` both say so where the agent reads it:
| How it arrives | What the model sees |
|---|---|
| Ambient | System prompt: title, `env.NAME`, catalog, "use describeBinding before using it" |
| Agent asked for it | User turn: "available as `env.NAME` … Use describeBinding(\"NAME\")" |
| **I attach it** | **`[Title](env.NAME)`** |
An attached *file* in that same function gets `[Attached text file (name)]\n`. Files give the model content; resources give it a name.
Every chat where I attach something now opens with the model reasoning about what the bindings probably are.
Contributor guide
Research direction
Start at the `msg.capsules` branch in `runAgent` and compare attached-resource formatting with the ambient and agent-requested resource instructions described in the issue. Check the attached-file handling in the same function; done means an attached resource gives the agent its type, API, and `describeBinding` guidance instead of only `[Title](env.NAME)`.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- ai
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 72/100