Keep document bodies out of the cacheable system prompt
buildDocumentsSection was inlining up to 5 document bodies at 2000 chars each into the system prompt. Any edit to any of the listed documents between wakes invalidated the Anthropic prompt cache — the prefix that buildTaskPrompt spent real effort to keep stable. Emit metadata only (id, type, title, author, status, version, updatedAt) and teach agents to GET the single-document endpoint when they actually need the body. The single-doc route did not exist, so add it; update the API doc block in the system prompt accordingly.
This commit is contained in:
1 parent
3a02b4d0a6
commit
9c65291973
3 files changed
+35
-14
No files matched your search
@@ -118,6 +118,24 @@ export function registerFileRoutes(server: AgentApiServer) {
|
||||
server.json(res, 200, docs);
|
||||
});
|
||||
|
||||
server.addRoute("GET", "/api/companies/:companyId/documents/:documentId", (_req, res, params, token) => {
|
||||
if (params.companyId !== token.companyId) {
|
||||
server.json(res, 403, { error: "Company mismatch" });
|
||||
return;
|
||||
}
|
||||
const documentId = params.documentId;
|
||||
if (!documentId) {
|
||||
server.json(res, 400, { error: "Missing documentId" });
|
||||
return;
|
||||
}
|
||||
const doc = db.getDocumentForUpdate(documentId, token.companyId);
|
||||
if (!doc) {
|
||||
server.json(res, 404, { error: "Document not found in this company" });
|
||||
return;
|
||||
}
|
||||
server.json(res, 200, doc);
|
||||
});
|
||||
|
||||
server.addRoute("PATCH", "/api/companies/:companyId/documents/:documentId", (_req, res, params, token, body) => {
|
||||
if (params.companyId !== token.companyId) {
|
||||
server.json(res, 403, { error: "Company mismatch" });
|
||||
|
||||
Reference in new issue
Block a user