perf: optimize prefix caching by skipping system prompt rebuild on every step (#9080)

This commit is contained in:
Sarah Wooders
2026-02-06 18:08:34 -08:00
committed by Caren Thomas
parent 825019c2ce
commit 9dbe28e8f1
8 changed files with 488 additions and 133 deletions

View File

@@ -6717,6 +6717,151 @@
}
}
},
"/v1/agents/{agent_id}/recompile": {
"post": {
"tags": ["agents"],
"summary": "Recompile Agent",
"description": "Manually trigger system prompt recompilation for an agent.",
"operationId": "recompile_agent",
"parameters": [
{
"name": "agent_id",
"in": "path",
"required": true,
"schema": {
"type": "string",
"minLength": 42,
"maxLength": 42,
"pattern": "^agent-[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$",
"description": "The ID of the agent in the format 'agent-<uuid4>'",
"examples": ["agent-123e4567-e89b-42d3-8456-426614174000"],
"title": "Agent Id"
},
"description": "The ID of the agent in the format 'agent-<uuid4>'"
},
{
"name": "update_timestamp",
"in": "query",
"required": false,
"schema": {
"type": "boolean",
"description": "If True, update the in-context memory last edit timestamp embedded in the system prompt.",
"default": false,
"title": "Update Timestamp"
},
"description": "If True, update the in-context memory last edit timestamp embedded in the system prompt."
},
{
"name": "dry_run",
"in": "query",
"required": false,
"schema": {
"type": "boolean",
"description": "If True, do not persist changes; still returns the compiled system prompt.",
"default": false,
"title": "Dry Run"
},
"description": "If True, do not persist changes; still returns the compiled system prompt."
}
],
"responses": {
"200": {
"description": "Successful Response",
"content": {
"application/json": {
"schema": {
"type": "string",
"title": "Response Recompile Agent"
}
}
}
},
"422": {
"description": "Validation Error",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/HTTPValidationError"
}
}
}
}
}
}
},
"/v1/agents/{agent_id}/system-prompt/recompile": {
"post": {
"tags": ["agents"],
"summary": "Recompile Agent System Prompt",
"description": "Deprecated alias for POST /v1/agents/{agent_id}/recompile.",
"operationId": "recompile_agent_system_prompt",
"deprecated": true,
"parameters": [
{
"name": "agent_id",
"in": "path",
"required": true,
"schema": {
"type": "string",
"minLength": 42,
"maxLength": 42,
"pattern": "^agent-[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$",
"description": "The ID of the agent in the format 'agent-<uuid4>'",
"examples": ["agent-123e4567-e89b-42d3-8456-426614174000"],
"title": "Agent Id"
},
"description": "The ID of the agent in the format 'agent-<uuid4>'"
},
{
"name": "update_timestamp",
"in": "query",
"required": false,
"schema": {
"type": "boolean",
"description": "If True, update the in-context memory last edit timestamp embedded in the system prompt.",
"default": false,
"title": "Update Timestamp"
},
"description": "If True, update the in-context memory last edit timestamp embedded in the system prompt."
},
{
"name": "dry_run",
"in": "query",
"required": false,
"schema": {
"type": "boolean",
"description": "If True, do not persist changes; still returns the compiled system prompt.",
"default": false,
"title": "Dry Run"
},
"description": "If True, do not persist changes; still returns the compiled system prompt."
}
],
"responses": {
"200": {
"description": "Successful Response",
"content": {
"application/json": {
"schema": {
"type": "string",
"title": "Response Recompile Agent System Prompt"
}
}
}
},
"422": {
"description": "Validation Error",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/HTTPValidationError"
}
}
}
}
}
}
},
"/v1/agents/{agent_id}/core-memory/blocks/attach/{block_id}": {
"patch": {
"tags": ["agents"],