Skip to content

fix: stop recursion through pipelines at the depth limit - #177

Open
ferdingler wants to merge 1 commit into
strands-agents:mainfrom
ferdingler:fix/recursion-limit-in-pipelines
Open

ferdingler wants to merge 1 commit into
strands-agents:mainfrom
ferdingler:fix/recursion-limit-in-pipelines

Conversation

@ferdingler

@ferdingler ferdingler commented Oct 21, 2026 •

Copy link
Copy Markdown
Collaborator

Description

If a function calls itself as part of a pipeline, like f() { f | cat; }; f, the shell runs until the timeout instead of stopping at the recursion limit. A function called directly counts toward the limit, and so do subshells and command substitutions, but a function running as one stage of a pipeline didn't.

Now a function in a pipeline stage counts as one more level of depth, the same as a direct call, so this kind of recursion stops right away at the configured limit. Normal nested pipelines under the limit behave the same as before.

I added a regression test with a small depth limit. On main it ran until the timeout; with the change it stops after a few calls and finishes instantly. I also checked that two levels of functions through pipelines still work under the same limit. One thing I noticed but left alone: errors printed from inside a function that runs as a pipeline stage don't reach the caller's stderr, so the recursion error itself isn't visible there. That's a separate fix.

Related Issues

None

Documentation PR

None

Type of Change

Bug fix

Testing

How have you tested the change? Verify that the changes do not break functionality or introduce new warnings.

  • I ran the relevant test suites for the bindings I touched (cargo test --workspace --all-targets, pytest tests/python, npm test)
  • If I touched Rust, I ran cargo fmt and cargo clippy

Checklist

  • I have read the CONTRIBUTING document
  • I have reviewed and understand every line of code in this PR, including any generated by AI tools, and I can explain why it works
  • My change is focused and reasonably small; I have split unrelated work into separate PRs
  • I have added any necessary tests that prove my fix is effective or my feature works
  • I have updated the documentation accordingly
  • I have added an appropriate example to the documentation to outline the feature, or no new docs are needed
  • My changes generate no new warnings
  • Any dependent changes have been merged and published

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@ferdingler
ferdingler requested a review from a team as a code owner October 21, 2026 05:10
@ferdingler
ferdingler requested review from Unshure and removed request for a team October 21, 2026 05:10

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant