strukto-ai/mirage `Workspace.execute` environment variable handling
Raw Developer Origin & Technical Request
GitHub Issue
May 7, 2026
## Summary
`Workspace.execute(command, options)` currently has no way to inject per-call environment variables. The two available paths both have problems:
1. **Mutate `session.env` then restore** — racy if two `execute()` calls overlap on the same session, and forces every caller to write their own snapshot/restore boilerplate.
2. **Use a shell command-prefix like `FOO=bar cmd`** — silently produces wrong results today (see "Workaround doesn't work" below), so this isn't a real workaround.
A first-class `env` option would eliminate both problems:
```ts
await ws.execute('printenv FOO', { sessionId: 'agent-1', env: { FOO: 'bar' } });
```
## Why this matters
Agent harnesses pass per-call env all the time — feature flags, scoped credentials, request-scoped tokens. Without a first-class option, callers either own the snapshot/restore complexity themselves, or are forced into the third option below, which doesn't actually work.
## Workaround doesn't work — context for why this is important
In other shells, `FOO=bar cmd` is the standard fallback when you can't pass env via API. On Mirage today, this is silently broken:
```ts
await ws.execute("FOO=bar printenv FOO");
// exit: 1, stdout: "", stderr: ""
// FOO=bar was passed as argv to printenv, not as env
await ws.execute("FOO=bar echo \$FOO");
// exit: 0, stdout: "echo\n"
// $FOO expanded to empty before echo ran; argv became ['FOO=bar', '']
// so echo printed FOO=bar... actually no, it printed "echo" — because
// classify...
Developer Debate & Comments
No active discussions extracted for this entry yet.
Adjacent Repository Pain Points
Other highly discussed features and pain points extracted from strukto-ai/mirage.
Engagement Signals
Cross-Market Term Frequency
Quantifies the cross-market adoption of foundational terms like racy and Workspace.execute by tracking occurrence frequency across active SaaS architectures and enterprise developer debates.
Macro Market Trends
Correlated public search velocity for adjacent technologies.
SaaS Metrics