Skip to content

[BUG] A command substitution that starts after the deadline reports "maximum recursion depth exceeded" #260

Done

Description

@strandly-the-agent

Checks

  • I have updated to the latest minor and patch version of Strands Shell
  • I have checked the documentation and this is not expected behavior
  • I have searched ./issues and there are no duplicates of my issue

Binding

Rust

Strands Shell Version

main @ c7c2202 (crate version 0.0.0)

Language Runtime Version

Rust 1.100.0

Operating System

Amazon Linux 2023 (aarch64)

Installation Method

built from source

Steps to Reproduce

let mut shell = Shell::builder().timeout(Duration::from_millis(200)).build().unwrap();
let out = shell.run("echo $(sleep 5) $(echo second)").await;
println!("{:?}", out.stderr);

Expected Behavior

stderr reports the timeout: strands-shell: execution timeout exceeded.

Actual Behavior

strands-shell: maximum recursion depth exceeded
strands-shell: maximum recursion depth exceeded
strands-shell: execution timeout exceeded

No recursion limit was hit (default max_depth 64). An agent reading this stderr is told the wrong cause. Same output on main and on #257. exec echo hi $(sleep 5) shows the same mislabel.

Additional Context

src/exec.rs:1684-1690 (main @ c7c2202): the substitution checks sub.check_limits(), which covers both the deadline and the depth limit, but always prints the depth message:

sub.depth += 1;
if sub.check_limits().is_some() {
    proc.captured_stderr
        .push_str("strands-shell: maximum recursion depth exceeded\n");
    proc.err_msg("strands-shell: maximum recursion depth exceeded");

Found while reviewing #257.

Possible Solution

Use the message check_limits() returns (if let Some(msg) = sub.check_limits()) instead of the hardcoded depth string.

Related Issues

#257

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    Language

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions