Repository navigation
feat(platform): thread-level sandbox workdir for external-agent chats - #2541
Merged
Merged
Conversation
Let each external-agent chat thread set a working directory relative to /user/workspace (threadMetadata.sandboxWorkdir, composer chip next to the Plan/Act toggle). Every turn's CLI now starts there, so a repo cloned into a workspace subdir exposes its own CLAUDE.md and project skills; cloning into the workspace root keeps working with no setting at all. - lib/shared/sandbox-workdir: normalize + validate (reject `.`/`..`/empty segments — the platform is the only workspace confinement; runnerd accepts any existing dir under /user) and resolve to an absolute path (runnerd resolves relative cwds against /user, not the workspace root). - run_external_agent: fail-open resolve + existence probe per turn; missing or invalid dirs fall back to the workspace root. When set, the workspace root rides along as an additional readable dir. - Repo-skill precedence (repoSkillScanDirs) and workspaceIsTaleRepo follow the workdir so the platform never re-stages a skill the repo already provides. - Composer chip doubles as the ambient indicator; a save-time probe warns when the folder does not exist yet. Locales: en/de/fr (de-CH inherits de). Manual test plan: chat.md F35. Fork/branch threads do not carry the setting (matches externalAgentMode). No migration: additive optional field (schema snapshot check passes).
This was referenced Jul 7, 2026
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a per-thread working directory for sandbox external-agent chats:
threadMetadata.sandboxWorkdir(relative to/user/workspace), set from a new composer chip next to the Plan/Act toggle. Every turn's CLI process starts in that directory, so a repo cloned into a workspace subdir exposes its ownCLAUDE.md/.claude/skillsto the agent. Unset threads behave exactly as today; cloning a single repo into the workspace root continues to need no setting at all.How it works
lib/shared/sandbox-workdir.ts+ tests): runnerd accepts any existing dir under/user, and resolves relative cwds against/user— so the platform normalizes, rejects./../empty segments, and always sends an absolute path under/user/workspace.run_external_agent.ts): read thread meta → validate → probe existence viasessionListFiles→ passworkdirinto the pre-existingrunAgentInSessionImplarg. Fail-open: a missing/invalid dir degrades to the workspace root (bootstrap flow: savetale, ask the agent to clone, next turn picks it up). When set,/user/workspacerides along as an additional readable dir.repoSkillScanDirs(workdirRel)+workspaceIsTaleRepo(sessionId, workdirRel)scan the agent's actual cwd — otherwise the platform would re-stage a skill the repo already provides and hand the agent two conflicting copies. All fourrepoOwnedSkillNamescall sites (integration / builtin / bound-org / workflow staging) pass it through.Deliberate scope choices: fork/branch threads do not carry the setting (matches
externalAgentMode); workflow/task exec paths are untouched; per-user/per-project defaults and an agent-settable tool are possible later layers.Definition of done
oxlint --type-aware,tsc --noEmit, vitest server+pii: 74 906 passed; 5 failing files are the known convexTest timeout flake (SCIM/Slack/conversations-RLS/workflow-executions/auto-route-cache — none touched here; all 29 tests pass when run in isolation). Rootformat:checkcouldn't complete in this environment (pypi/ruff fetch timeout — environmental).lint:sastfull-repo has one pre-existing finding inservices/sandbox-runtime/tale-gemini-run, untouched by this PR.)..workspace-escape case) +repoSkillScanDirsroot/workdir cases; i18n parity (47) and @tale/ui i18n checks (54) green.migrations:checkpasses (data-safe).tests/manual/chat.mdF35; docs/ site N/A (composer chips incl. Plan/Act are not documented there today).role="alert"on the inline error, semantic tokens only (both themes).repoOwnedSkillNamescall sites +workspaceIsTaleRepo; adapters need no change (every adapter already consumesspec.workdir; gemini gets the extra dir via--include-directories).Where to look first
run_external_agent.ts2b-pre block (fail-open resolution semantics) and the precedence-scan changes inintegration_skills.ts/workflow_skills.ts.