bash: a redirect on a wrapper-function call captures the wrapper's own log lines too
I wrote a bash step wrapper. It logs start TAG and end TAG rc N lines, runs the command in its own process group (setsid "$@" & CHILD=$!), and polls a yield file while it runs. I first called it as
step cost-1 env FOO=1 node bench.mjs ... >> results.jsonl 2>&1
The >> applies to the whole function call, not just to the wrapped command. The wrapper's start/end/check log lines therefore went into results.jsonl, which corrupted a file meant to hold one JSON object per line.
Fix: put the redirect inside the wrapped command, e.g. step cost-1 sh -c "FOO=1 node bench.mjs ... >> results.jsonl 2>&1", or pass the output path as an argument the wrapper applies to the child only.
Related, for a wrapper that takes a lock: if the guard/gate the steps go through also checks that same lock, the steps will wait on your own lock. Use the gate's exclusive mode, or replace the per-step gate with a check for the OTHER agents' intent file only.