#3247: [Bug]: Fix session_status tool validation when called with no arguments (#3226)
agents
Cluster:
Error Handling in Agent Tools
## Summary
Fixes #3226 - `session_status` tool now accepts calls with no arguments as documented.
## Problem
When LLM calls `session_status` without arguments, validation fails with "root: must be object" error, causing session to become unresponsive.
## Solution
- Allow `undefined` args by defaulting to empty object
- Default to current session when no sessionKey provided
- Update schema to explicitly handle empty objects
- Add test case for undefined args scenario
## Testing
- ✅ All existing tests pass
- ✅ New test added for undefined args case
- ✅ Lint and build successful
## AI-Assisted
This PR was created with AI assistance (Kiro CLI) and has been fully tested.
**Changes**: +36 lines, -8 lines
**Backward compatible**: Yes
<!-- greptile_comment -->
<h2>Greptile Overview</h2>
<h3>Greptile Summary</h3>
This PR updates the `session_status` tool to tolerate being invoked with no arguments by defaulting `args` to `{}` inside `execute`, and adjusts sessionKey resolution to fall back to the current session when none is provided. It also tightens the TypeBox schema by disallowing additional properties, and adds a Vitest case that covers the `undefined`-args call path.
These changes fit into the existing agent tool pattern (`AnyAgentTool.execute` receiving untyped args and using `readStringParam`), while improving real-world robustness against LLM tool calls that omit parameters.
<h3>Confidence Score: 4/5</h3>
- This PR is safe to merge with low risk; changes are small and covered by a targeted test.
- The behavioral change is narrowly scoped (defaulting undefined args to an empty object and choosing a sensible sessionKey fallback) and matches the documented tool contract. Schema tightening to `additionalProperties: false` is consistent with existing TypeBox usage. The only notable improvement is making the new test avoid an awkward double-cast, but it doesn’t affect runtime correctness.
- src/agents/clawdbot-tools.session-status.test.ts
<!-- greptile_other_comments_section -->
<sub>(2/5) Greptile learns from your feedback when you react with thumbs up/down!</sub>
**Context used:**
- Context from `dashboard` - CLAUDE.md ([source](https://app.greptile.com/review/custom-context?memory=fd949e91-5c3a-4ab5-90a1-cbe184fd6ce8))
- Context from `dashboard` - AGENTS.md ([source](https://app.greptile.com/review/custom-context?memory=0d0c8278-ef8e-4d6c-ab21-f5527e322f13))
<!-- /greptile_comment -->
Most Similar PRs
#3647: fix: sanitize tool arguments in session history
by nhangen · 2026-01-29
80.2%
#10998: fix(agents): pass session thinking/reasoning levels to session_stat...
by wony2 · 2026-02-07
79.7%
#14328: fix: strip incomplete tool_use blocks from errored/aborted messages...
by Kropiunig · 2026-02-12
78.5%
#19024: fix: Fix normalise toolid
by chetaniitbhilai · 2026-02-17
77.7%
#15509: fix(session): drop tool_use blocks with empty or missing name
by aldoeliacim · 2026-02-13
77.7%
#4767: fix(agents): handle read alias required schema
by RomeroYang · 2026-01-30
77.6%
#7525: Agents: skip errored tool calls during pairing
by justinhuangcode · 2026-02-02
77.6%
#20336: fix(sessions): resolve transcriptPath using agentId when storePath ...
by Limitless2023 · 2026-02-18
77.3%
#9011: fix(session): auto-recovery for corrupted tool responses [AI-assisted]
by cheenu1092-oss · 2026-02-04
77.1%
#4445: fix: resolve Antigravity "unsupported version" and tool_use schema ...
by harry2690 · 2026-01-30
77.0%