Skip to content

The open-source agent harness - the runtime layer that turns an LLM into a working agent.

chore: TFY sandbox should discover working directory before writing files (#711)

Srajan Asthanaba79ce540f25
diff --git a/.changeset/tfy-sandbox-pwd-instructions.md b/.changeset/tfy-sandbox-pwd-instructions.md
new file mode 100644
index 000000000..ae1c43a66
--- /dev/null
+++ b/.changeset/tfy-sandbox-pwd-instructions.md
@@ -0,0 +1,5 @@
+---
+"@truefoundry/trueforge-core": patch
+---
+
+Add TFY sandbox agent instructions to discover the working directory via `pwd` before writing files.
diff --git a/packages/trueforge-core/src/core/sandbox/provider/TFYSandboxProvider.ts b/packages/trueforge-core/src/core/sandbox/provider/TFYSandboxProvider.ts
index 2db77cf2b..7544eba18 100644
--- a/packages/trueforge-core/src/core/sandbox/provider/TFYSandboxProvider.ts
+++ b/packages/trueforge-core/src/core/sandbox/provider/TFYSandboxProvider.ts
@@ -251,8 +251,9 @@ export class TFYSandboxProvider implements SandboxProvider {
getAdditionalInstructions(): string {
return dedent`
SANDBOX RULES:
- - uploads, skills, and tool-results live in the sandbox working directory (not /tmp or /opt).
- - ALL file creation and writes MUST stay within the sandbox working directory.
+ - The Agent's first sandbox command should be \`pwd\` to discover the working directory.
+ - uploads, skills, and tool-results live in that working directory (not /tmp or /opt).
+ - ALL file creation and writes MUST stay within that working directory.
- The Agent must NOT write to /tmp/, ~/, or any absolute path outside the working directory.
`;
}
diff --git a/packages/trueforge-core/tests/core/sandbox/provider/tfyLayout.test.ts b/packages/trueforge-core/tests/core/sandbox/provider/tfyLayout.test.ts
index 4599e05d7..686077ea1 100644
--- a/packages/trueforge-core/tests/core/sandbox/provider/tfyLayout.test.ts
+++ b/packages/trueforge-core/tests/core/sandbox/provider/tfyLayout.test.ts
@@ -26,7 +26,10 @@ describe('TFYSandboxProvider layout', () => {
expect(install.remotePath.startsWith('/')).toBe(false);
expect(install.pathBinSymlink).toBeUndefined();
const instructions = provider.getAdditionalInstructions();
- expect(instructions).toContain('uploads, skills, and tool-results live in the sandbox working directory');
+ expect(instructions).toContain(
+ "The Agent's first sandbox command should be `pwd` to discover the working directory.",
+ );
+ expect(instructions).toContain('uploads, skills, and tool-results live in that working directory');
expect(instructions).not.toContain('/data/sandboxes');
});