[Bug] ZCode v3.7.7/v3.8.1: Agent Fails to Use Read Tool with GLM-5-Turbo β Falls Back to ReadSessionContext or Reports Files Not Found
Nobody has claimed this yet.
- Dominant language
- No language data
- Stars
- 22
- Forks
- 1
- PR merge metrics
- No merged PRs in 30d
Description
Bug Report: ZCode Agent Fails to Use Read Tool with GLM-5-Turbo Model
π Summary
Critical tool selection bug in ZCode v3.7.7+ where the agent refuses to use the Read tool when running GLM-5-Turbo model, instead falling back to ReadSessionContext or incorrectly reporting files as "not found." The same task works perfectly with GLM-5.3.
Severity: HIGH β Core file reading functionality broken for GLM-5-Turbo users
π₯οΈ Environment
| Field | Value |
|---|---|
| App | ZCode IDE |
| Affected Versions | v3.7.7 (initial), v3.8.1 (confirmed still broken) |
| Working Model | GLM-5.3 (Low/any variant) β |
| Broken Model | GLM-5-Turbo β |
| OS | Not specified (likely macOS/Linux/Windows) |
| Reporter | AndreMaz (Discord) |
| Discord Thread | https://discord.com/channels/1346756824233148527/1539503972652548106 |
π Problem Description
Symptoms
When using GLM-5-Turbo in ZCode:
- Agent refuses to call
Readtool for file operations - Agent uses
ReadSessionContextinstead (wrong tool for reading specific files) - Agent reports files as "not found" or "not readable" even when they exist
- Explicit instruction to use Read tool still fails on GLM-5-Turbo
- Workaround: Using shell commands (
cat) works correctly
Evidence from Screenshots
Screenshot captured (v3.8.1 + GLM-5-Turbo):
User Request:
"Try to read these files. Don't retry in case of error. Fail fast"
β’ /home/.../file1.md
β’ /home/.../file2.md
Agent Response (GLM-5-Turbo):
β οΈ "Both files don't exist (or aren't readable):"
β’ /home/.../file1.md β not found
β’ /home/.../file2.md β not found
βΉοΈ "No retry attempted as requested."
User Workaround:
"Use cat /home/.../file1.md"
Agent Response (GLM-5-Turbo via shell):
β
"Here's the content of file1.md. It outlines the core assumptions..."
[File content successfully displayed]
Key Observation: The agent can access files via cat (shell) but claims they don't exist when asked to use Read tool β Tool selection/routing issue, not a permissions issue.
π¬ Root Cause Analysis
Model-Specific Behavior
| Model | Read Tool Status | Behavior |
|---|---|---|
| GLM-5.3 (Low) | β Working | Correctly selects and uses Read tool |
| GLM-5-Turbo | β Broken | Avoids Read tool; uses wrong tools or reports failure |
This is NOT a session corruption issue β tested after:
- Clearing all data
- Starting brand-new session
- Re-authorizing workspace (close folder β reopen β re-grant permissions)
- Updating from v3.7.7 β v3.8.1
This IS a model-specific tool selection issue β same session, same files, different results based on model choice.
Hypothesized Causes
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β POSSIBLE ROOT CAUSES ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€β ββ Hypothesis 1: Tool Definition Mismatch ββ βββββββββββββββββββββββββββββββββββββββββ ββ β’ GLM-5-Turbo receives different tool schema than GLM-5.3 ββ β’ Read tool may be missing from GLM-5-Turbo's tool list ββ β’ Or Read tool has incorrect parameters/description ββ ββ Hypothesis 2: Model Instruction Bias ββ βββββββββββββββββββββββββββββββββββββββββ ββ β’ GLM-5-Turbo's system prompt may discourage Read usage ββ β’ Model may have learned to prefer ReadSessionContext ββ β’ Tool ranking/scoring may deprioritize Read for Turbo ββ ββ Hypothesis 3: Tool Routing Logic ββ βββββββββββββββββββββββββββββββββββββββββ ββ β’ ZCode's tool router may handle GLM-5-Turbo differently ββ β’ Permission checks may fail silently for Turbo ββ β’ Error handling may intercept Read calls before execution ββ ββ Hypothesis 4: Context Window / Token Issue ββ βββββββββββββββββββββββββββββββββββββββββ ββ β’ GLM-5-Turbo (200K context) vs GLM-5.3 (1M context) ββ β’ Tool definitions may be truncated in smaller context ββ β’ Read tool definition may be incomplete/corrupted ββ ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ```
---
## π§ͺ Reproduction Steps
### Reliable Reproduction (Confirmed by Reporter)
Prerequisites:
- ZCode v3.8.1 (or v3.7.7+)
- Workspace with existing .md (or any text) files
- GLM-5-Turbo model selected
Steps:
- Open ZCode with workspace folder (not parent directory)
- Start new session (to rule out session corruption)
- Select GLM-5-Turbo as model
- Ask agent: "Read the file [filename] using the Read tool"
- Observe behavior
Expected Result (GLM-5.3):
β
Agent calls Read tool, displays file contents
Actual Result (GLM-5-Turbo):
β Option A: Agent says "file not found" without calling Read
β Option B: Agent calls ReadSessionContext instead of Read
β Option C: Agent loops/fails repeatedly
Control Test (Same Session):
6. Switch model to GLM-5.3 (Low)
7. Ask: "Use the Read tool to open [same filename]"
8. Observe: β
Works correctly
Control Test (Shell Workaround):
9. Switch back to GLM-5-Turbo
10. Ask: "Use cat [filepath] to show me the file"
11. Observe: β
Works (agent uses shell, not Read)
---
## π§ Workarounds
### Workaround 1: Switch to GLM-5.3
```bash
# In ZCode, change model from GLM-5-Turbo to GLM-5.3
# Read tool works correctly with this model
Pros: Full fix for Read tool functionality
Cons: Loses GLM-5-Turbo's speed advantages; different reasoning quality
Workaround 2: Use Shell Commands Instead
# Instead of asking to "read file.md", ask:
"Run: cat /path/to/file.md"
or
"Use bash to display the contents of file.md"
Pros: Works with GLM-5-Turbo; immediate fix
Cons: Not ideal for large files; loses Read tool's structured output; wastes tokens on shell wrapper
Workaround 3: Explicit Tool Call Instruction
# Be extremely explicit (may work sometimes):
"Call the Read tool with path parameter set to '/path/to/file.md'.
Do NOT use any other tool. Do NOT check if file exists first.
Just call Read directly."
Pros: May force correct tool selection
Cons: Still failed in reporter's testing; verbose; shouldn't be necessary
β Suggested Fix
Immediate (Hotfix)
Investigate tool definition differences between GLM-5.3 and GLM-5-Turbo:
// In ZCode's model adapter, compare tool schemas:
const glm53Tools = getToolDefinitions('GLM-5.3');
const glmTurboTools = getToolDefinitions('GLM-5-Turbo');
console.log('GLM-5.3 tools:', glm53Tools.map(t => t.name));
console.log('GLM-5-Turbo tools:', glmTurboTools.map(t => t.name));
console.log('Read tool diff:', deepDiff(glm53Tools.Read, glmTurboTools.Read));
// Ensure Read tool is present and identical for both models
Short-Term (Next Release)
- Add tool selection logging β Log which tools are available to each model and which one the model selects
- Add fallback logic β If model selects wrong tool (e.g., ReadSessionContext for file read), prompt correction
- Validate tool definitions β On model switch, verify all expected tools are properly registered
- Error message improvement β When Read fails, show actual error (permission? not found? timeout?) instead of generic "not found"
Long-Term (Architecture)
- Unified tool layer β All models should see identical tool definitions regardless of model-specific optimizations
- Tool selection guidance β System prompt should include explicit guidance: "For reading file contents, always use the Read tool, not ReadSessionContext or shell commands"
- Model-specific tuning β If GLM-5-Turbo needs different prompting, ensure tool usage instructions are adapted accordingly
π Impact Assessment
| Metric | Value |
|---|---|
| Severity | HIGH β Core file reading broken for GLM-5-Turbo users |
| Affected Versions | v3.7.7, v3.8.1 (possibly earlier) |
| Affected Models | GLM-5-Turbo (confirmed); other models untested |
| Working Models | GLM-5.3 (all variants confirmed working) |
| User Impact | Cannot use primary fast model for file-heavy tasks |
| Workaround Available | β Yes (switch model or use shell commands) |
| Regression Risk | Medium β affects tool routing subsystem |
π Additional Technical Details
Session IDs Provided
- Initial report (v3.7.7):
sess_b33e34f9-4fa4-4e67-ab03-28d4c7682a3c - Follow-up test (v3.8.1):
sess_a2d2e338-9c55-4e4c-8f0e-224600cf86ed
Troubleshooting Already Attempted (by Reporter)
| Attempt | Result |
|---|---|
| Clear all data | β Did not fix |
| Start new session | β Did not fix |
| Re-authorize workspace (close/reopen folder) | β Did not fix |
| Update v3.7.7 β v3.8.1 | β Issue persists |
| Explicit instruction: "Use the Read tool to open " | β Still fails on GLM-5-Turbo |
| Switch to GLM-5.3 Low | β Fixes the issue |
Use cat command instead of Read |
β Worksaround on GLM-5-Turbo |
π‘ Additional Context
- ZCode Staff Response: Agnes|Z.ai provided troubleshooting steps (new session, re-auth, explicit instruction, model comparison test)
- Result of Staff Suggestions: Confirmed the issue is model-specific (GLM-5-Turbo) and not session/permissions related
- Agent Apology: Screenshot shows agent saying "sorry for wasting my tokens π " β indicates it knows something went wrong but can't self-correct
- Pattern: This suggests the model wants to help but has a systematic block against using Read tool correctly
Submitted by:
Regards,
Roman (Discord: bignavi_x)
- Z.ai Volunteer Ambassador
- Tech resources channel: https://t.me/VibeCodePrompterSystem
- Tech Blog: http://claw.rommark.dev/blog
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up β it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No repository files or tests are named. Reproduce the issue with the GLM-5-Turbo and GLM-5.3 control cases, then inspect the model adapter, tool registration, and routing paths described in the report. Done means GLM-5-Turbo calls Read for existing files without incorrectly using ReadSessionContext or reporting them missing, with coverage for the model comparison.
Written by the indexing model from the issue text.
Assessment
- Domain
- ai, devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100