Agentic Logic

Save a code rule's draft

PUT /v25-10-beta/agentic-logic/rules/{ruleId}/draft

Saves the draft of a code rule. The response is { draft }. A builder rule answers 400.

  • source (string, required) — The rule source.
  • dependencies (array, optional) — Must be empty: rules run with no npm packages.
  • userTestSuite / generatedTestSuite (string, optional) — Omit to keep the stored suite; send "" to clear it.
  • validationScenarios (array, optional) — Scenarios the publish checks run the rule against. Omit to keep the stored ones; send [] to discard them.
  • graph (object, optional) — The rule graph for this source, checked against it at save time. When omitted, the stored graph is kept only if the source is unchanged.
  • origin (chat or manual, optional) — Where the source came from. Omit to keep the stored value.
  • autoAssist (boolean, optional) — Whether the save starts AI assistance. Defaults to true. Send false to only store the draft (see below). Applies to this call only; it is not stored on the rule.

Every save replaces the previous draft. Publish snapshots the draft, so an in-flight publish is not affected by a later save. Unless autoAssist is false, a save also:

  • Regenerates the rule graph with AI when the saved draft has no graph.
  • Regenerates the AI-generated validation scenarios when they no longer cover the source's attempt() branches. Scenarios you authored are kept.

The first save of a draft rule that has never had a publish job, and that does not send autoAssist: false, also starts a dry run of the publish checks. If the checks fail, an AI repair loop rewrites the draft and runs them again, within its attempt, time, and cost limits. Once the checks pass, the rule is published without any further call. If a rewrite changed what the rule does, the loop stops instead and leaves the rewritten draft for a person to publish.

Saving a draft does not stop a running repair loop. If you save while the loop is rewriting, the loop's rewrite is dropped, that attempt counts against its limit, and the loop decides its next step from your draft.

With autoAssist: false, the save starts neither the regeneration above nor the dry run, and it does not stop a repair loop that is already running. A later save without the flag still starts the dry run while the rule has never had a publish job. A later publish still works: with no graph the graph check passes with a note, with no scenarios the default scenario is used, and the AI test suite is generated at publish time.

A save that omits validationScenarios keeps the stored ones unchanged, so scenarios from an earlier save, including AI-generated ones, carry forward and may no longer match the new source's branches. While they do not, the scenarios listing reports pending until a save without autoAssist: false regenerates them, or a save sends a full generated set: sent scenarios replace the stored ones rather than adding to them.

Use the intelligems-access-token header. The token selects the organization; do not send orgId. The organization must have Agentic Logic enabled.

Rate Limit: 50 requests per 30s window, refilling 25 tokens every 30s.

put/v25-10-beta/agentic-logic/rules/{ruleId}/draft

Request

Path parameters

ruleIdstring uuid required

Request body

sourcestring required

Draft rule source code.

userTestSuitestring

User-authored test suite to persist with the draft. Omit to leave the existing suite untouched; send an empty string to clear it.

generatedTestSuitestring

Edits to the AI-generated test suite. Omit to leave the stored suite untouched; send an empty string to clear it and let the next publish generate a fresh one. An explicit suite is stored as hand-authored, so the next publish runs it to decide whether it still covers the rule rather than assuming either way.

origin'chat' | 'manual'

Provenance of the submitted source: 'chat' when the editor buffer was applied from the workspace AI chat and untouched since, 'manual' when a person authored or last edited it. Omit to leave the stored provenance untouched.

autoAssistboolean

Whether the save starts AI assistance. Defaults to true. False stores the draft without starting AI graph or scenario regeneration, the initial dry run, or a repair loop; a repair loop already running is not stopped. Applies to this call only.

Response

OK

Changes

No recorded changes to this operation across all 1 revision of this API.