cloudwego / cloudwego/eino

Conflict between reduction and filesystem middleware

Open
#860 0 comments 0 reactions 0 assignees View on GitHub
C-bug D-adk
Dominant language
Go
Stars
13k
Forks
1.1k
Avg merge
4h 6m
Merged PRs (30d)
41

Description

**Describe the bug**

1. Tool call returns a long _single_ line rather than multiline content
2. Gets truncated/off-loaded
3. read_file on the content
4. read_file response is then truncated once again
5. loops

The reduction middleware may truncate or completely offload content to a file which the agent then makes use of the filesystem middleware to read said truncated/off loaded content. If this content is a single long line, then no amount of filesystem.Read() will work, the agent will be stuck in a loop.

**To Reproduce**

Steps to reproduce the behavior:
1. Add recommended middleware(s)
2. CM response with a very long single line
3. Tool gets truncated
4. Agent reads file with contents
5. Output is truncated

**Expected behavior**

(a) read_file result to NOT have the same redaction message **(do not re-offload it)**
(b) read_file to consider content with long single lines (aka: columns not just lines)

**Screenshots**

N/A

**Version:**

v0.8.1

**Environment:**

N/A

**Additional context**

The [middleware recommendations](https://www.cloudwego.io/docs/eino/release_notes_and_migration/eino_v0.8._-adk_middlewares/#middleware-usage-recommendations) only work well when a model has reasoning content. The reasoning content gets held back and then the model can understand even though the content has been off-loaded or redacted. This should probably be mentioned, along with some configuration examples for different cases.

Alternatively, a scratchpad can be added for the agent to note down important things (which should not get redacted) but I've found this to be so-so but that might just be my prompting.

**EDIT:** I've also noticed that the off-loaded content is in `json` rather than just the content of the tool output. I'm not sure if this is intentional. I believe this is also adding to the single line issue as the json takes the content from multi line to single line (Obviously ignoring the fact that some tool somewhere may still return a very long line that these tools should account for)

**EDIT2** It also keeps re-adding line numbers when off-loading the read file. See example:
```json
[
{
"role": "tool",
"content": " 1\t 1\t 1\t 1\t 1\t 1\t{\"content\":[{\"type\":\"text\",\"text\":\"# take_snapshot response\\n## Page content\\nuid=1_0 RootWebArea \\\"OWASP Juice Shop\\\" backendNodeId=\\\"2\\\" loaderId=\\\"\\\" url=\\\"http://juice-shop:3000/#/contact\\\"\\n uid=1_1 button \\\"Open Sidenav\\\" backendNodeId=\\\"64\\\" description=\\\"Open side menu\\\" loaderId=\\\"\\\"\\n uid=1_2 button \\\"Back to homepage\\\" backendNodeId=\\\"65\\\" loaderId=\\\"\\\"\\n uid=1_3 textbox \\\"\\\" backendNodeId=\\\"3\\\" disableable disabled loaderId=\\\"\\\"\\n uid=1_4 button \\\"Show/hide account menu\\\" backendNodeId=\\\"16\\\" expandable haspopup=\\\"menu\\\" loaderId=\\\"\\\"\\n uid=1_5 button \\\"Language selection menu\\\" backendNodeId=\\\"69\\\" description=\\\"Choose language\\\" expandable haspopup=\\\"menu\\\" loaderId=\\\"\\\"\\n uid=1_6 heading \\\"Customer Feedback\\\" backendNodeId=\\\"140\\\" level=\\\"1\\\" loaderId=\\\"\\\"\\n uid=1_7 StaticText \\\"Author\\\" backendNodeId=\\\"421\\\" loaderId=\\\"\\\"\\n uid=1_8 textbox \\\"Field with the name of the author\\\" backendNodeId=\\\"5\\\" disableable disabled loaderId=\\\"\\\" value=\\\"anonymous\\\"\\n uid=1_9 generic \\\"\\\" atomic backendNodeId=\\\"207\\\" live=\\\"polite\\\" loaderId=\\\"\\\" relevant=\\\"additions text\\\"\\n uid=1_10 StaticText \\\"Comment\\\" backendNodeId=\\\"423\\\" loaderId=\\\"\\\"\\n uid=1_11 textbox \\\"Field for entering the comment or the feedback\\\" backendNodeId=\\\"6\\\" description=\\\"Max. 160 characters 0/160\\\" loaderId=\\\"\\\" multiline required\\n uid=1_12 generic \\\"\\\" atomic backendNodeId=\\\"167\\\" live=\\\"polite\\\" loaderId=\\\"\\\" relevant=\\\"additions text\\\"\\n uid=1_13 StaticText \\\"Max. 160 characters\\\" backendNodeId=\\\"426\\\" loaderId=\\\"\\\"\\n uid=1_14 StaticText \\\"0/160\\\" backendNodeId=\\\"428\\\" loaderId=\\\"\\\"\\n uid=1_15 StaticText \\\"Rating\\\" backendNodeId=\\\"429\\\" loaderId=\\\"\\\"\\n uid=1_16 slider \\\"\\\" backendNodeId=\\\"72\\\" loaderId=\\\"\\\" orientation=\\\"horizontal\\\" value=\\\"1\\\" valuemax=\\\"5\\\" valuemin=\\\"1\\\" valuetext=\\\"1★\\\"\\n uid=1_17 StaticText \\\"1★\\\" backendNodeId=\\\"430\\\" loaderId=\\\"\\\"\\n uid=1_18 StaticText \\\"CAPTCHA:\\\" backendNodeId=\\\"431\\\" loaderId=\\\"\\\"\\n uid=1_19 StaticText \\\"   \\\" backendNodeId=\\\"432\\\" loaderId=\\\"\\\"\\n uid=1_20 StaticText \\\"What is\\\" backendNodeId=\\\"433\\\" loaderId=\\\"\\\"\\n uid=1_21 StaticText \\\"  \\\" backendNodeId=\\\"38\\\" loaderId=\\\"\\\"\\n uid=1_22 StaticText \\\"9-2-5\\\" backendNodeId=\\\"434\\\" loaderId=\\\"\\\"\\n uid=1_23 StaticText \\\"  \\\" backendNodeId=\\\"39\\\" loaderId=\\\"\\\"\\n uid=1_24 StaticText \\\"?\\\" backendNodeId=\\\"40\\\" loaderId=\\\"\\\"\\n uid=1_25 StaticText \\\"Result\\\" backendNodeId=\\\"435\\\" loaderId=\\\"\\\"\\n uid=1_26 textbox \\\"Field for the result of the CAPTCHA code\\\" backendNodeId=\\\"7\\\" loaderId=\\\"\\\" required\\n uid=1_27 generic \\\"\\\" atomic backendNodeId=\\\"149\\\" live=\\\"polite\\\" loaderId=\\\"\\\" relevant=\\\"additions text\\\"\\n uid=1_28 button \\\"Button to send the review\\\" backendNodeId=\\\"74\\\" disableable disabled loaderId=\\\"\\\"\\n uid=1_29 generic \\\"\\\" atomic backendNodeId=\\\"89\\\" live=\\\"polite\\\" loaderId=\\\"\\\" relevant=\\\"additions text\\\"\\n\"}]}\n 2\t 2\t 2\t 2\t 2\t\n 3\t 3\t 3\t\n 4\t",
"tool_call_id": "toolu_01LekAiWoKTCmPFddiXWf5X6",
"tool_name": "read_file"
}
]
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.