Start an Improve run
const url = 'https://example.com/v1/improve-runs';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"agentId":"example","projectId":"2489E9AD-2EE2-8E00-8EC9-32D5F69181C0","tiers":["settings"],"model":{"providerId":"example","model":"example"},"candidates":1,"groupWeights":"as-recorded","objective":"passRate","budget":{"maxCostUsd":1,"maxCandidates":1}}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://example.com/v1/improve-runs \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "agentId": "example", "projectId": "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0", "tiers": [ "settings" ], "model": { "providerId": "example", "model": "example" }, "candidates": 1, "groupWeights": "as-recorded", "objective": "passRate", "budget": { "maxCostUsd": 1, "maxCandidates": 1 } }'Starts an Improve run for an agent in a project. From the version the project runs (pinned there, else its Latest), it looks for better wording (the prompt tier) or settings values (the settings tier) on the project’s test set, learning from the project’s open corrections sorted to improve, within the budget. Its best change is proven on every case of the test set, at the reference’s repetitions: when it passes more cases than that version and fails none that passed, it becomes a suggested change for a reviewer. It answers at once with the Improve run, running. Under kindgi dev, the run counts in its project (its corrections, its test set and its cost), and its suggested change is for the whole workspace (the tenant scope), which the pack’s files serve: pinning it writes its block into the pack’s files. The readiness check (POST /v1/improve-runs/check) runs first: when something the Improve run needs is missing, it’s refused with 409 improve-not-ready, listing every missing item at once (details.items, each with its fix); while the agent has a running Improve run in the project, with 409 improve-run-running (details.improveRunId). An Improve run going when its project is suspended ends cancelled, with the reason in cancelReason. Needs publish on the agent; for an agent more than one project serves, write where its versions are made. Without Improve runs in this runtime, 501 improve-unsupported.
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Header Parameters
Section titled “Header Parameters”Request Bodyrequired
Section titled “Request Bodyrequired”Start an Improve run for an agent in a project, or check one first. It starts from the version the project runs, learns from the project’s corrections, and searches and proves on the project’s test set. A field not listed here is refused (400 bad-input, naming it).
object
Responses
Section titled “Responses”The Improve run, running.
An Improve run: the runtime looking for better wording or settings values for an agent in a project, on the project’s test set, within a budget. A candidate that does better becomes a suggested change.
object
Example
{ "startsFrom": { "follows": "pin" }, "tiers": [ "settings" ], "objective": "passRate", "groupWeights": "as-recorded", "status": "running", "outcome": { "kind": "suggested" }, "comparisons": [ { "role": "reference", "part": "search" } ]}Malformed request body (bad-input): no projectId, or a field the body doesn’t have (scope, testSetId and fromVersion among them), named in the message.
object
Examplegenerated
{ "error": { "code": "example", "message": "example", "details": {}, "requestId": "example" }}Missing / malformed / expired / revoked bearer token.
object
Examplegenerated
{ "error": { "code": "example", "message": "example", "details": {}, "requestId": "example" }}No publish on the agent, or, for an agent more than one project serves, no write on the project its new versions are made in (permission-denied). Without an authorization store, key-project-mismatch (details.keyProjectId, details.projectId): the API key or session is limited to a project, and this starts work in another one, where the item is, where it runs, where its new versions are made, or where the conversation it continues is (with a store, that is permission-denied).
object
Examplegenerated
{ "error": { "code": "example", "message": "example", "details": {}, "requestId": "example" }}The body’s projectId names no project of this workspace, or a deleted one (project-not-found).
object
Examplegenerated
{ "error": { "code": "example", "message": "example", "details": {}, "requestId": "example" }}improve-not-ready: something the Improve run needs is missing (details.items, as POST /v1/improve-runs/check lists them). improve-run-running: the agent has a running Improve run in the project (details.improveRunId); one runs at a time. Or registry-read-only: the agent registry is read-only and takes no versions an Improve run makes; the message says why. Or Idempotency-Key was reused with a different body. Or idempotency-key-in-flight (with Retry-After): a request with the same Idempotency-Key still runs, so this one wasn’t run; send it again after Retry-After to get that request’s answer.
object
Examplegenerated
{ "error": { "code": "example", "message": "example", "details": {}, "requestId": "example" }}Headers
Section titled “Headers”The request body is over the API’s limit (request-too-large; details.maxBytes says how much).
object
Examplegenerated
{ "error": { "code": "example", "message": "example", "details": {}, "requestId": "example" }}rate-limit-exceeded with details.limit: "api-requests", on a runtime that sets workspace limits (Kindgi Cloud): this workspace’s limit on API requests a minute is reached, so the request wasn’t run; Retry-After says when to send it again.
object
Examplegenerated
{ "error": { "code": "example", "message": "example", "details": {}, "requestId": "example" }}Headers
Section titled “Headers”Server error (unmapped domain code or framework crash).
object
Examplegenerated
{ "error": { "code": "example", "message": "example", "details": {}, "requestId": "example" }}improve-unsupported: this runtime runs no Improve runs.
object
Examplegenerated
{ "error": { "code": "example", "message": "example", "details": {}, "requestId": "example" }}The Idempotency-Key store (idempotency-store-unavailable) or the authorization store (authz-backend-unavailable) couldn’t be reached before the request ran, or the database was too busy for its authorization check (database-busy), so nothing was changed; Retry-After (whole seconds) says when to try again with the same key. Or tenant-state-unavailable (with Retry-After), on a runtime serving many workspaces: the workspace’s state couldn’t be read, so nothing was changed.
object
Examplegenerated
{ "error": { "code": "example", "message": "example", "details": {}, "requestId": "example" }}Headers
Section titled “Headers”See also
GET /v1/improve-runs: List Improve runs- Kindgi 0.4.0
- Error code
authz-backend-unavailable - Error code
bad-input - Error code
database-busy - Error code
idempotency-key-in-flight - Error code
idempotency-store-unavailable - Error code
improve-not-ready - Error code
improve-run-running - Error code
improve-unsupported - Error code
key-project-mismatch - Error code
permission-denied - Error code
project-not-found - Error code
rate-limit-exceeded - Error code
registry-read-only - Error code
request-too-large - Error code
tenant-state-unavailable - Every error code