Hand files between a local coding agent and Praxis
Send local policy.pdf to a cloud knowledge base, search its refund policy, and save the search response as local result.json. File bytes bypass model context.
Prerequisites
Connect Praxis through one of the three ways in, with the ability to run codemode, and same-organization File and Knowledge access. Prepare a nonempty, unencrypted PDF containing refund terms, at most 100000000 bytes, and install curl locally. All JavaScript below runs in codemode; all bash runs in your local shell. Cloud bash cannot read your local PDF.
Replace placeholders with actual returned values. Codemode calls are independent; no variable carries over. Signed URLs are credentials: disclose only to the requester, keep in transient shell variables with tracing disabled, and never save them to files, logs, or source control.
1. Upload the local PDF
wc -c < policy.pdfReplace local_byte_count with the integer output and sign in cloud codemode:
import { praxis } from "praxis";export default async () => praxis.file.uploads.createSigned({ body: { filename: "policy.pdf", bytes: local_byte_count, content_type: "application/pdf", purpose: "user_data"} });After the call finishes, pass its url as local transient variable upload_url, then run:
curl --fail-with-body -T policy.pdf -H 'Content-Type: application/pdf' "$upload_url"Expect 201 with id (used as file_id below). This recipe fits single PUT. Do not replay a successful upload.
2. Create a store and attach the file
import { praxis } from "praxis";export default async () => praxis.knowledge.vectorStores.create({ body: { name: "Policy transfer demo" } });Use the returned id as store_id:
import { praxis } from "praxis";export default async () => praxis.knowledge.vectorStores.files.create({ path: { vector_store_id: "store_id" }, body: { file_id: "file_id" }});Expect an attachment with the same id as file_id, possibly in_progress. Upload and ingestion are separate.
3. Wait until searchable
import { praxis } from "praxis";export default async () => praxis.knowledge.vectorStores.files.retrieve({ path: { vector_store_id: "store_id", file_id: "file_id" }});Repeat at two-second intervals for at most five minutes. Continue only at status: "completed". Stop on failed or cancelled and inspect last_error; on timeout report status rather than creating duplicate attachments.
4. Search and create a result file
import { praxis } from "praxis";export default async () => { const result = await praxis.knowledge.vectorStores.search.create({ path: { vector_store_id: "store_id" }, body: { query: "What is the refund policy?", max_num_results: 5 } }); if (!result.data.length) throw new Error("No matching chunks; check ingestion and PDF text"); const file = await praxis.file.uploadFile( new File([JSON.stringify(result, null, 2)], "result.json", { type: "application/json" }), { purpose: "user_data" } ); return { result_file_id: file.id, matches: result.data.length };};Expect matches greater than zero and result_file_id. The file contains the search response, rather than a model-written answer. The upload helper waits until active.
5. Download and verify
Replace file_id with the preceding result_file_id:
import { praxis } from "praxis";export default async () => praxis.file.files.contentUrl.create({ path: { file_id: "file_id" }, body: { ttl_seconds: 3600 }});curl -fsSL -o result.json "$download_url"test -s result.jsonpython3 -c 'import json; r=json.load(open("result.json")); assert len(r["data"]) > 0; print("search results saved")'Expect search results saved. Open the file to inspect refund-policy sources. The link defaults to 900 seconds, permits repeated downloads, and lasts at most 604800 seconds.
Failures and cleanup
Upload 400: correct byte count and Content-Type. 410 CAPABILITY_USED: upload already succeeded; do not replay it. Link 404: check organization and file state, then sign again. If File is processing, poll praxis.file.files.retrieve with delays until active; stop on failure or timeout. Inline MCP FileRefs up to 5 MiB enter conversation context without saving to disk.
After downloading, revoke the link by substituting its token after /c/; revocation propagates within 15 minutes without deleting the file:
import { praxis } from "praxis";export default async () => praxis.file.files.contentLinks.revoke({ path: { file_id: "RESULT_file_id" }, body: { token: "content_token" }});After verifying results, clean up the test store, source PDF, and result file according to your organization’s retention policy. Deleting a store does not automatically delete source Files.