fix(pi): expose Taskflow run identity to child agents
Problem
pi-taskflow launches each agent phase as an isolated pi --mode json -p child, but the child environment does not contain an orchestration run identity such as PI_SUBAGENT_RUN_ID.
That makes the child indistinguishable from an inline/root Pi process to packages that enforce child-only or async-start execution. A concrete example is dev-loops: GitHub-first routes with workflow.asyncStartMode: required reject startup even though they are running inside an isolated Taskflow child, because neither DEVLOOPS_RUN_ID nor the Pi runtime alias PI_SUBAGENT_RUN_ID is present.
The current Pi runner only forwards process.env plus Shared Context Tree variables. RunOptions also does not carry the owning Taskflow runId, although both imperative and event-kernel execution contexts have it.
Proposed scope
Expose the owning Taskflow run identity through the host-neutral runner seam and have the Pi adapter set the established Pi child marker:
- add an optional orchestration run identifier to
RunOptions; - pass the persisted Taskflow
state.runIdon every agent call in both imperative and event-kernel paths; - set
PI_SUBAGENT_RUN_IDin the spawned Pi child environment when that identifier is present; - do not add a general arbitrary-environment escape hatch;
- keep non-Pi host adapters behavior unchanged unless they intentionally consume the optional field.
Acceptance criteria
- [ ] Pi agent children receive
PI_SUBAGENT_RUN_ID=<owning Taskflow run id>. - [ ] The value comes from persisted Taskflow state, not a fabricated constant or caller-controlled flow field.
- [ ] Both imperative and event-kernel agent paths propagate it.
- [ ] Direct
runAgentTaskcallers that provide no run identity retain current behavior. - [ ] Unit tests cover propagation into the spawned child environment and the two core execution paths.
- [ ] Existing typecheck and Pi/core tests remain green.
Non-goals
- Passing arbitrary flow-defined environment variables into children.
- Loading ambient extensions into isolated Pi children.
- Weakening downstream async-start checks.