Remove cheap model profiles (#12683)
## Thinking Path > - Paperclip manages agents that use different model providers and adapters. > - Paperclip must keep agent execution rules clear and predictable. > - The cheap-model profile added a second execution mode across adapters, task recovery, APIs, and the UI. > - That mode increased configuration and recovery complexity. > - This pull request removes the cheap-model profile as a product feature. > - The benefit is one model-selection path for normal work and recovery work. ## Linked Issues or Issue Description **What existing behavior does this improve?** This change simplifies model selection across agent configuration, task execution, recovery, and adapter capabilities. **Current behavior** Paperclip exposes cheap-model profiles in adapter metadata, agent runtime configuration, task overrides, recovery rules, APIs, and the board UI. Recovery work can select a different model profile from the agent's configured model. **Proposed behavior** Paperclip uses the agent's configured model for normal work and recovery work. Status-only recovery stays limited to coordination work. The API rejects legacy model-profile configuration. A migration removes stored model-profile values from existing agent, issue, and historical revision records. **Reason and benefit** One model path reduces configuration, API, UI, and recovery complexity. It also prevents status recovery from becoming a separate product-level model-routing feature. **Breaking changes** This change removes model-profile fields and adapter capability metadata. Existing stored model-profile values are removed by an idempotent migration. The validators reject new legacy profile values with clear errors. ## What Changed - Removed model-profile types, adapter capabilities, API fields, and model selection logic. - Removed cheap-model controls from agent and task UI surfaces. - Kept status-only recovery limited to coordination context while normal continuations use the configured agent model. - Added an idempotent migration that removes stored model-profile values from agents, issues, and configuration revisions without changing issue update timestamps. - Updated tests and product documentation for the single-model behavior. ## Verification - `pnpm check:token-gates` passes. - `pnpm -r typecheck` passes. - `pnpm build` passes. - `pnpm test:run` completed with 5,607 passing tests and 8 environment-sensitive failures in unrelated fixed-port and database-deadlock suites. The same failures repeated in an isolated rerun. CI is the final clean-room result. ## Risks - This is an intentional breaking change for clients that send model-profile fields. - The migration changes legacy agent, issue, and configuration-revision JSON. It is idempotent and preserves unrelated fields and issue update timestamps. - The change is cross-cutting because the removed feature existed in adapters, shared contracts, the server, plugins, and the UI. > For core feature work, check [`ROADMAP.md`](ROADMAP.md) first and discuss it in `#dev` before opening the PR. Feature PRs that overlap with planned core work may need to be redirected — check the roadmap first. See `CONTRIBUTING.md`. ## Model Used - OpenAI Codex with `gpt-5`. Reasoning and tool use were enabled. The runtime did not expose the context-window size. ## Checklist - [x] I have included a thinking path that traces from project context to this change - [x] I have specified the model used (with version and capability details) - [x] I have checked ROADMAP.md and confirmed this PR does not duplicate planned core work - [x] I have searched GitHub for duplicate or related PRs and linked them above - [x] I have either (a) linked existing issues with `Fixes: #` / `Closes #` / `Refs #` OR (b) described the issue in-PR following the relevant issue template - [x] I have not referenced internal/instance-local Paperclip issues or links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip` URLs) - [ ] My branch name describes the change (e.g. `docs/...`, `fix/...`) and contains no internal Paperclip ticket id or instance-derived details - [ ] I have run tests locally and they pass - [x] I have added or updated tests where applicable - [x] I have updated relevant documentation to reflect my changes - [x] I have considered and documented any risks above - [x] All Paperclip CI gates are green - [x] Greptile is 5/5 with no open P2s, recommendations, or follow-ups - [x] I will address all Greptile and reviewer comments before requesting merge --------- Co-authored-by: Paperclip <noreply@paperclip.ing>
This commit is contained in:
parent
1ab159d3a7
commit
4b6de5327e
|
|
@ -90,7 +90,6 @@ describe("admin, asset, and skill parity commands", () => {
|
|||
await run(["adapter", "config-schema", "codex_local"]);
|
||||
await run(["adapter", "ui-parser", "codex_local"]);
|
||||
await run(["adapter", "models", "codex_local", "--company-id", COMPANY_ID, "--refresh", "--environment-id", "env-1"]);
|
||||
await run(["adapter", "model-profiles", "codex_local", "--company-id", COMPANY_ID]);
|
||||
await run(["adapter", "detect-model", "codex_local", "--company-id", COMPANY_ID]);
|
||||
await run(["adapter", "test-environment", "codex_local", "--company-id", COMPANY_ID, "--payload-json", "{}"]);
|
||||
await run(["adapter", "delete", "codex_local"]);
|
||||
|
|
@ -107,7 +106,6 @@ describe("admin, asset, and skill parity commands", () => {
|
|||
["GET", "http://localhost:3100/api/adapters/codex_local/config-schema"],
|
||||
["GET", "http://localhost:3100/api/adapters/codex_local/ui-parser.js"],
|
||||
["GET", `http://localhost:3100/api/companies/${COMPANY_ID}/adapters/codex_local/models?refresh=true&environmentId=env-1`],
|
||||
["GET", `http://localhost:3100/api/companies/${COMPANY_ID}/adapters/codex_local/model-profiles`],
|
||||
["GET", `http://localhost:3100/api/companies/${COMPANY_ID}/adapters/codex_local/detect-model`],
|
||||
["POST", `http://localhost:3100/api/companies/${COMPANY_ID}/adapters/codex_local/test-environment`],
|
||||
["DELETE", "http://localhost:3100/api/adapters/codex_local"],
|
||||
|
|
|
|||
|
|
@ -122,7 +122,6 @@ export function registerAdapterCommands(program: Command): void {
|
|||
{ includeCompany: false },
|
||||
);
|
||||
|
||||
addCompanyAdapterGet(adapter, "model-profiles", "List adapter model profiles", "model-profiles");
|
||||
addCompanyAdapterGet(adapter, "detect-model", "Detect adapter model", "detect-model");
|
||||
addCompanyAdapterPost(adapter, "test-environment", "Test adapter environment configuration", "test-environment");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -899,7 +899,6 @@ npx paperclipai adapter delete <adapter-type>
|
|||
npx paperclipai adapter config-schema <adapter-type>
|
||||
npx paperclipai adapter ui-parser <adapter-type>
|
||||
npx paperclipai adapter models <adapter-type> --company-id <company-id> [--refresh] [--environment-id <id>]
|
||||
npx paperclipai adapter model-profiles <adapter-type> --company-id <company-id>
|
||||
npx paperclipai adapter detect-model <adapter-type> --company-id <company-id>
|
||||
npx paperclipai adapter test-environment <adapter-type> --company-id <company-id> --payload-json '{...}'
|
||||
```
|
||||
|
|
|
|||
|
|
@ -157,7 +157,7 @@ Invariant: every business record belongs to exactly one company.
|
|||
- `capabilities` text null
|
||||
- `adapter_type` text; built-ins include `process`, `http`, `claude_local`, `codex_local`, `gemini_local`, `opencode_local`, `pi_local`, `cursor`, `hermes_local`, `hermes_gateway`, and `openclaw_gateway`
|
||||
- `adapter_config` jsonb not null
|
||||
- `runtime_config` jsonb not null default `{}`; may include Paperclip runtime policy such as `modelProfiles.cheap.adapterConfig` for an optional low-cost model lane that does not change the primary adapter config
|
||||
- `runtime_config` jsonb not null default `{}`; contains Paperclip runtime policy such as heartbeat scheduling and debug settings
|
||||
- `default_environment_id` uuid fk `environments.id` null
|
||||
- `context_mode` enum: `thin | fat` default `thin`
|
||||
- `budget_monthly_cents` int not null default 0
|
||||
|
|
@ -1203,11 +1203,11 @@ Behavior:
|
|||
- `thin`: send IDs and pointers only; agent fetches context via API
|
||||
- `fat`: include current assignments, goal summary, budget snapshot, and recent comments
|
||||
|
||||
## 11.5 Recovery Model Profiles
|
||||
## 11.5 Recovery Work Classes
|
||||
|
||||
The optional `modelProfiles.cheap` lane is not a retry worker lane. Paperclip may request the cheap profile only for status-only recovery coordination, and those wakes must include guard context that prevents deliverable work and document/plan updates (`allowDeliverableWork: false`, `allowDocumentUpdates: false`, `resumeRequiresNormalModel: true`).
|
||||
Status-only recovery coordination must include guard context that prevents deliverable work and document or plan updates (`allowDeliverableWork: false`, `allowDocumentUpdates: false`, `resumeRequiresNormalModel: true`). Recovery work classes do not select or change the agent model.
|
||||
|
||||
Failed source-work retries, process-loss retries, transient/scheduled retries, max-turn continuations, source-assignee continuations, and downstream source-work child/requeue/resume contexts must use the normal/original model lane. If cheap recovery repairs liveness while actual work remains, the next live continuation path must be a separate normal-model worker run with cheap hints scrubbed.
|
||||
Failed source-work retries, process-loss retries, transient or scheduled retries, max-turn continuations, source-assignee continuations, and downstream source-work child, requeue, or resume contexts use the agent's configured model. If status-only recovery repairs liveness while actual work remains, the next live continuation path must be a separate worker run.
|
||||
|
||||
## 11.6 Scheduler Rules
|
||||
|
||||
|
|
|
|||
|
|
@ -573,11 +573,11 @@ An accepted interaction supersedes a continuation park recorded before that acce
|
|||
|
||||
This keeps the post-decomposition umbrella (§7) on a real waiting path instead of relying on `parentId` rollup, which §6 does not treat as a dependency.
|
||||
|
||||
### 9.3 Recovery model-profile lane
|
||||
### 9.3 Recovery work classes
|
||||
|
||||
Cheap model profiles are only for status-only operational recovery overhead. Paperclip may request `modelProfile: "cheap"` for bounded recovery-owner work that updates task liveness, clears bad status, records a disposition, or asks for human/manager intervention. Those wakes must carry guard context such as `allowDeliverableWork: false`, `allowDocumentUpdates: false`, and `resumeRequiresNormalModel: true`.
|
||||
Status-only operational recovery can update task liveness, clear bad status, record a disposition, or ask for human or manager intervention. Those wakes must carry guard context such as `allowDeliverableWork: false`, `allowDocumentUpdates: false`, and `resumeRequiresNormalModel: true`. The recovery work class does not select or change the agent model.
|
||||
|
||||
Automatic retries that can continue source work must use the original/normal model lane. This includes failed source-work retries, process-loss retries, transient/scheduled retries, max-turn continuations, source-assignee continuations, assigned-todo dispatch recovery, and any run that can update repo files, issue documents, plans, work products, or attachments. When a cheap status-only recovery determines that actual work remains, it must hand back to a normal-model worker run before source work or persistent deliverable updates resume. Cheap recovery hints must be scrubbed from copied retry, resume, child, and downstream source-work contexts.
|
||||
Automatic retries that can continue source work use the agent's configured model. This includes failed source-work retries, process-loss retries, transient or scheduled retries, max-turn continuations, source-assignee continuations, assigned-todo dispatch recovery, and any run that can update repo files, task documents, plans, work products, or attachments. When status-only recovery determines that actual work remains, it must hand back to a worker run before source work or persistent deliverable updates resume.
|
||||
|
||||
## 10. Startup and Periodic Reconciliation
|
||||
|
||||
|
|
|
|||
|
|
@ -25,8 +25,6 @@ export type {
|
|||
AdapterSkillContext,
|
||||
AdapterSessionCodec,
|
||||
AdapterModel,
|
||||
AdapterModelProfileKey,
|
||||
AdapterModelProfileDefinition,
|
||||
HireApprovedPayload,
|
||||
HireApprovedHookResult,
|
||||
ConfigFieldOption,
|
||||
|
|
|
|||
|
|
@ -232,16 +232,6 @@ export interface AdapterModel {
|
|||
label: string;
|
||||
}
|
||||
|
||||
export type AdapterModelProfileKey = "cheap";
|
||||
|
||||
export interface AdapterModelProfileDefinition {
|
||||
key: AdapterModelProfileKey;
|
||||
label: string;
|
||||
description?: string;
|
||||
adapterConfig: Record<string, unknown>;
|
||||
source?: "adapter_default" | "discovered";
|
||||
}
|
||||
|
||||
export type AdapterEnvironmentCheckLevel = "info" | "warn" | "error";
|
||||
|
||||
export interface AdapterEnvironmentCheck {
|
||||
|
|
@ -458,8 +448,6 @@ export interface ServerAdapterModule {
|
|||
runtimeToolDelivery?: AdapterRuntimeToolDelivery;
|
||||
models?: AdapterModel[];
|
||||
listModels?: () => Promise<AdapterModel[]>;
|
||||
modelProfiles?: AdapterModelProfileDefinition[];
|
||||
listModelProfiles?: () => Promise<AdapterModelProfileDefinition[]>;
|
||||
/**
|
||||
* Optional explicit refresh hook for model discovery.
|
||||
* Use this when the adapter caches discovered models and needs a bypass path
|
||||
|
|
@ -673,14 +661,6 @@ export interface CreateConfigValues {
|
|||
promptTemplate: string;
|
||||
model: string;
|
||||
thinkingEffort: string;
|
||||
/**
|
||||
* Optional cheap model profile config for new agents on adapters that
|
||||
* support model profiles. Persisted under
|
||||
* `runtimeConfig.modelProfiles.cheap.adapterConfig`, never on the primary
|
||||
* `adapterConfig`.
|
||||
*/
|
||||
cheapModel?: string;
|
||||
cheapModelEnabled?: boolean;
|
||||
chrome: boolean;
|
||||
dangerouslySkipPermissions: boolean;
|
||||
claudeEngine?: "auto" | "cli" | "acp";
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
import type { AdapterModelProfileDefinition } from "@paperclipai/adapter-utils";
|
||||
|
||||
export const type = "claude_local";
|
||||
export const label = "Claude Code";
|
||||
|
||||
|
|
@ -18,19 +16,6 @@ export const models = [
|
|||
{ id: "claude-haiku-4-5", label: "Claude Haiku 4.5" },
|
||||
];
|
||||
|
||||
export const modelProfiles: AdapterModelProfileDefinition[] = [
|
||||
{
|
||||
key: "cheap",
|
||||
label: "Cheap",
|
||||
description: "Use Claude Sonnet as the lower-cost Claude Code lane while preserving the agent's primary model.",
|
||||
adapterConfig: {
|
||||
model: "claude-sonnet-4-6",
|
||||
effort: "low",
|
||||
},
|
||||
source: "adapter_default",
|
||||
},
|
||||
];
|
||||
|
||||
export const agentConfigurationDoc = `# claude_local agent configuration
|
||||
|
||||
Adapter: claude_local
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
import type { AdapterModelProfileDefinition } from "@paperclipai/adapter-utils";
|
||||
|
||||
export const type = "codex_local";
|
||||
export const label = "Codex";
|
||||
|
||||
|
|
@ -74,16 +72,6 @@ export const models = [
|
|||
{ id: "codex-mini-latest", label: "Codex Mini" },
|
||||
];
|
||||
|
||||
export const modelProfiles: AdapterModelProfileDefinition[] = [
|
||||
{
|
||||
key: "cheap",
|
||||
label: "Cheap",
|
||||
description: "Use an explicitly configured lower-cost Codex model without changing the primary model.",
|
||||
adapterConfig: {},
|
||||
source: "adapter_default",
|
||||
},
|
||||
];
|
||||
|
||||
export const agentConfigurationDoc = `# codex_local agent configuration
|
||||
|
||||
Adapter: codex_local
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
import type { AdapterModelProfileDefinition } from "@paperclipai/adapter-utils";
|
||||
|
||||
export const type = "cursor";
|
||||
export const label = "Cursor";
|
||||
|
||||
|
|
@ -58,18 +56,6 @@ const CURSOR_FALLBACK_MODEL_IDS = [
|
|||
|
||||
export const models = CURSOR_FALLBACK_MODEL_IDS.map((id) => ({ id, label: id }));
|
||||
|
||||
export const modelProfiles: AdapterModelProfileDefinition[] = [
|
||||
{
|
||||
key: "cheap",
|
||||
label: "Cheap",
|
||||
description: "Use Cursor's known Codex mini model as the budget lane instead of assuming auto is cheap.",
|
||||
adapterConfig: {
|
||||
model: "gpt-5.1-codex-mini",
|
||||
},
|
||||
source: "adapter_default",
|
||||
},
|
||||
];
|
||||
|
||||
export const agentConfigurationDoc = `# cursor agent configuration
|
||||
|
||||
Adapter: cursor
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
import {
|
||||
buildSandboxNpmInstallCommand,
|
||||
type AdapterModelProfileDefinition,
|
||||
} from "@paperclipai/adapter-utils";
|
||||
|
||||
export const type = "gemini_local";
|
||||
|
|
@ -21,18 +20,6 @@ export const models = [
|
|||
{ id: "gemini-2.0-flash-lite", label: "Gemini 2.0 Flash Lite" },
|
||||
];
|
||||
|
||||
export const modelProfiles: AdapterModelProfileDefinition[] = [
|
||||
{
|
||||
key: "cheap",
|
||||
label: "Cheap",
|
||||
description: "Use Gemini Flash Lite as the budget Gemini CLI lane while preserving the primary model.",
|
||||
adapterConfig: {
|
||||
model: "gemini-2.5-flash-lite",
|
||||
},
|
||||
source: "adapter_default",
|
||||
},
|
||||
];
|
||||
|
||||
export const agentConfigurationDoc = `# gemini_local agent configuration
|
||||
|
||||
Adapter: gemini_local
|
||||
|
|
|
|||
|
|
@ -1,28 +0,0 @@
|
|||
import { describe, expect, it } from "vitest";
|
||||
import { buildOpenCodeModelProfiles, DEFAULT_OPENCODE_CHEAP_MODEL } from "./index.js";
|
||||
|
||||
describe("buildOpenCodeModelProfiles cheap lane", () => {
|
||||
it("defaults to the upstream Codex mini model with variant low", () => {
|
||||
const [cheap] = buildOpenCodeModelProfiles({});
|
||||
expect(cheap.key).toBe("cheap");
|
||||
expect(cheap.adapterConfig).toEqual({ model: DEFAULT_OPENCODE_CHEAP_MODEL, variant: "low" });
|
||||
});
|
||||
|
||||
it("uses PAPERCLIP_OPENCODE_CHEAP_MODEL when set (no variant, gateway models may not support it)", () => {
|
||||
const [cheap] = buildOpenCodeModelProfiles({ PAPERCLIP_OPENCODE_CHEAP_MODEL: "anthropic/gw/m" });
|
||||
expect(cheap.adapterConfig).toEqual({ model: "anthropic/gw/m" });
|
||||
});
|
||||
|
||||
it("falls back to PAPERCLIP_OPENCODE_SMALL_MODEL so one setting covers both budget lanes", () => {
|
||||
const [cheap] = buildOpenCodeModelProfiles({ PAPERCLIP_OPENCODE_SMALL_MODEL: "anthropic/gw/small" });
|
||||
expect(cheap.adapterConfig).toEqual({ model: "anthropic/gw/small" });
|
||||
});
|
||||
|
||||
it("prefers CHEAP_MODEL over SMALL_MODEL when both are set", () => {
|
||||
const [cheap] = buildOpenCodeModelProfiles({
|
||||
PAPERCLIP_OPENCODE_CHEAP_MODEL: "anthropic/gw/cheap",
|
||||
PAPERCLIP_OPENCODE_SMALL_MODEL: "anthropic/gw/small",
|
||||
});
|
||||
expect(cheap.adapterConfig).toEqual({ model: "anthropic/gw/cheap" });
|
||||
});
|
||||
});
|
||||
|
|
@ -1,5 +1,3 @@
|
|||
import type { AdapterModelProfileDefinition } from "@paperclipai/adapter-utils";
|
||||
|
||||
export const type = "opencode_local";
|
||||
export const label = "OpenCode";
|
||||
|
||||
|
|
@ -63,41 +61,6 @@ export const models: Array<{ id: string; label: string }> = [
|
|||
{ id: "openai/gpt-5.1-codex-mini", label: "openai/gpt-5.1-codex-mini" },
|
||||
];
|
||||
|
||||
export const DEFAULT_OPENCODE_CHEAP_MODEL = "openai/gpt-5.1-codex-mini";
|
||||
|
||||
// The "cheap" budget profile (used for recovery retries and other low-cost lanes).
|
||||
// Defaults to OpenCode's known Codex mini model, but is overridable so a deployment
|
||||
// routing through a gateway that does not serve that model (e.g. an EU LLM gateway)
|
||||
// can point the budget lane at a gateway-served model instead -- otherwise recovery
|
||||
// retries fail with "model not found". PAPERCLIP_OPENCODE_CHEAP_MODEL takes priority;
|
||||
// PAPERCLIP_OPENCODE_SMALL_MODEL (the auxiliary/title model) is reused as a sensible
|
||||
// fallback so a single setting covers both budget lanes. The default keeps the
|
||||
// upstream behaviour (with the Codex `variant: "low"`).
|
||||
//
|
||||
// This module is shared client/server code (the UI imports it for
|
||||
// DEFAULT_OPENCODE_LOCAL_MODEL etc.), so it must not touch the global `process`
|
||||
// unguarded: in the browser (Vite dev middleware serves it untransformed)
|
||||
// a bare `process.env` throws ReferenceError at module load and takes the whole
|
||||
// app down. Guard with `typeof process` and fall back to an empty env.
|
||||
export function buildOpenCodeModelProfiles(
|
||||
env: NodeJS.ProcessEnv = typeof process === "undefined" ? {} : process.env,
|
||||
): AdapterModelProfileDefinition[] {
|
||||
const override = (env.PAPERCLIP_OPENCODE_CHEAP_MODEL ?? env.PAPERCLIP_OPENCODE_SMALL_MODEL)?.trim();
|
||||
return [
|
||||
{
|
||||
key: "cheap",
|
||||
label: "Cheap",
|
||||
description: "Budget lane model for recovery retries and other low-cost tasks.",
|
||||
adapterConfig: override
|
||||
? { model: override }
|
||||
: { model: DEFAULT_OPENCODE_CHEAP_MODEL, variant: "low" },
|
||||
source: "adapter_default",
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
export const modelProfiles: AdapterModelProfileDefinition[] = buildOpenCodeModelProfiles();
|
||||
|
||||
export const agentConfigurationDoc = `# opencode_local agent configuration
|
||||
|
||||
Adapter: opencode_local
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
import type { AdapterModelProfileDefinition } from "@paperclipai/adapter-utils";
|
||||
|
||||
export const type = "pi_local";
|
||||
export const label = "Pi";
|
||||
|
||||
|
|
@ -7,8 +5,6 @@ export const SANDBOX_INSTALL_COMMAND = "npm install -g @earendil-works/pi-coding
|
|||
|
||||
export const models: Array<{ id: string; label: string }> = [];
|
||||
|
||||
export const modelProfiles: AdapterModelProfileDefinition[] = [];
|
||||
|
||||
export const agentConfigurationDoc = `# pi_local agent configuration
|
||||
|
||||
Adapter: pi_local
|
||||
|
|
|
|||
|
|
@ -1904,4 +1904,100 @@ describeEmbeddedPostgres("applyPendingMigrations", () => {
|
|||
},
|
||||
30_000,
|
||||
);
|
||||
|
||||
it(
|
||||
"removes retired model profiles from live records and configuration revisions",
|
||||
async () => {
|
||||
const connectionString = await createTempDatabase();
|
||||
await applyPendingMigrations(connectionString);
|
||||
const hash = await migrationHash("0236_remove_cheap_model_profiles.sql");
|
||||
const companyId = "10000000-0000-4000-8000-000000000236";
|
||||
const agentId = "20000000-0000-4000-8000-000000000236";
|
||||
const issueId = "30000000-0000-4000-8000-000000000236";
|
||||
const sql = postgres(connectionString, { max: 1, onnotice: () => {} });
|
||||
|
||||
try {
|
||||
await sql`
|
||||
INSERT INTO companies (id, name, issue_prefix)
|
||||
VALUES (${companyId}, 'Model profile migration fixture', 'MPF')
|
||||
`;
|
||||
await sql`
|
||||
INSERT INTO agents (id, company_id, name, runtime_config)
|
||||
VALUES (
|
||||
${agentId},
|
||||
${companyId},
|
||||
'Legacy model profile agent',
|
||||
'{"heartbeat":{"enabled":true},"modelProfiles":{"cheap":{"model":"legacy"}}}'::jsonb
|
||||
)
|
||||
`;
|
||||
await sql`
|
||||
INSERT INTO issues (id, company_id, title, assignee_adapter_overrides)
|
||||
VALUES (
|
||||
${issueId},
|
||||
${companyId},
|
||||
'Legacy model profile issue',
|
||||
'{"modelProfile":"cheap","workingDirectory":"/workspace"}'::jsonb
|
||||
)
|
||||
`;
|
||||
await sql`
|
||||
INSERT INTO agent_config_revisions (
|
||||
company_id,
|
||||
agent_id,
|
||||
changed_keys,
|
||||
before_config,
|
||||
after_config
|
||||
)
|
||||
VALUES (
|
||||
${companyId},
|
||||
${agentId},
|
||||
'["runtimeConfig"]'::jsonb,
|
||||
'{"name":"Legacy model profile agent","runtimeConfig":{"modelProfiles":{"cheap":{"model":"legacy-before"}},"heartbeat":{"enabled":true}}}'::jsonb,
|
||||
'{"name":"Legacy model profile agent","runtimeConfig":{"modelProfiles":{"cheap":{"model":"legacy-after"}},"heartbeat":{"enabled":false}}}'::jsonb
|
||||
)
|
||||
`;
|
||||
await sql`
|
||||
DELETE FROM "drizzle"."__drizzle_migrations"
|
||||
WHERE "hash" = ${hash}
|
||||
`;
|
||||
} finally {
|
||||
await sql.end();
|
||||
}
|
||||
|
||||
await applyPendingMigrations(connectionString);
|
||||
|
||||
const verifySql = postgres(connectionString, { max: 1, onnotice: () => {} });
|
||||
try {
|
||||
const [result] = await verifySql.unsafe<{
|
||||
runtime_config: Record<string, unknown>;
|
||||
assignee_adapter_overrides: Record<string, unknown> | null;
|
||||
before_config: Record<string, unknown>;
|
||||
after_config: Record<string, unknown>;
|
||||
}[]>(`
|
||||
SELECT
|
||||
agent.runtime_config,
|
||||
issue.assignee_adapter_overrides,
|
||||
revision.before_config,
|
||||
revision.after_config
|
||||
FROM agents agent
|
||||
JOIN issues issue ON issue.company_id = agent.company_id
|
||||
JOIN agent_config_revisions revision ON revision.agent_id = agent.id
|
||||
WHERE agent.id = '${agentId}' AND issue.id = '${issueId}'
|
||||
`);
|
||||
|
||||
expect(result.runtime_config).toEqual({ heartbeat: { enabled: true } });
|
||||
expect(result.assignee_adapter_overrides).toEqual({ workingDirectory: "/workspace" });
|
||||
expect(result.before_config).toEqual({
|
||||
name: "Legacy model profile agent",
|
||||
runtimeConfig: { heartbeat: { enabled: true } },
|
||||
});
|
||||
expect(result.after_config).toEqual({
|
||||
name: "Legacy model profile agent",
|
||||
runtimeConfig: { heartbeat: { enabled: false } },
|
||||
});
|
||||
} finally {
|
||||
await verifySql.end();
|
||||
}
|
||||
},
|
||||
30_000,
|
||||
);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -0,0 +1,108 @@
|
|||
CREATE INDEX IF NOT EXISTS "agents_remove_model_profiles_idx"
|
||||
ON "agents" USING btree ("id")
|
||||
WHERE "runtime_config" ? 'modelProfiles';--> statement-breakpoint
|
||||
|
||||
DO $$
|
||||
DECLARE
|
||||
updated_count integer;
|
||||
BEGIN
|
||||
LOOP
|
||||
WITH batch AS MATERIALIZED (
|
||||
SELECT "id"
|
||||
FROM "agents"
|
||||
WHERE "runtime_config" ? 'modelProfiles'
|
||||
ORDER BY "id"
|
||||
LIMIT 1000
|
||||
)
|
||||
UPDATE "agents" AS agent
|
||||
SET "runtime_config" = agent."runtime_config" - 'modelProfiles',
|
||||
"updated_at" = now()
|
||||
FROM batch
|
||||
WHERE agent."id" = batch."id";
|
||||
|
||||
GET DIAGNOSTICS updated_count = ROW_COUNT;
|
||||
EXIT WHEN updated_count = 0;
|
||||
END LOOP;
|
||||
END $$;--> statement-breakpoint
|
||||
|
||||
DROP INDEX IF EXISTS "agents_remove_model_profiles_idx";--> statement-breakpoint
|
||||
|
||||
-- paperclip:migration-safety-ignore large-create-index-not-concurrently: This temporary partial index covers only revision snapshots with the retired JSON key and is dropped after the bounded cleanup.
|
||||
CREATE INDEX IF NOT EXISTS "agent_config_revisions_remove_model_profiles_idx"
|
||||
ON "agent_config_revisions" USING btree ("id")
|
||||
WHERE ("before_config" #> '{runtimeConfig}') ? 'modelProfiles'
|
||||
OR ("after_config" #> '{runtimeConfig}') ? 'modelProfiles';--> statement-breakpoint
|
||||
|
||||
DO $$
|
||||
DECLARE
|
||||
updated_count integer;
|
||||
BEGIN
|
||||
LOOP
|
||||
WITH batch AS MATERIALIZED (
|
||||
SELECT "id"
|
||||
FROM "agent_config_revisions"
|
||||
WHERE ("before_config" #> '{runtimeConfig}') ? 'modelProfiles'
|
||||
OR ("after_config" #> '{runtimeConfig}') ? 'modelProfiles'
|
||||
ORDER BY "id"
|
||||
LIMIT 1000
|
||||
)
|
||||
UPDATE "agent_config_revisions" AS revision
|
||||
SET "before_config" = CASE
|
||||
WHEN (revision."before_config" #> '{runtimeConfig}') ? 'modelProfiles'
|
||||
THEN jsonb_set(
|
||||
revision."before_config",
|
||||
'{runtimeConfig}',
|
||||
(revision."before_config" #> '{runtimeConfig}') - 'modelProfiles'
|
||||
)
|
||||
ELSE revision."before_config"
|
||||
END,
|
||||
"after_config" = CASE
|
||||
WHEN (revision."after_config" #> '{runtimeConfig}') ? 'modelProfiles'
|
||||
THEN jsonb_set(
|
||||
revision."after_config",
|
||||
'{runtimeConfig}',
|
||||
(revision."after_config" #> '{runtimeConfig}') - 'modelProfiles'
|
||||
)
|
||||
ELSE revision."after_config"
|
||||
END
|
||||
FROM batch
|
||||
WHERE revision."id" = batch."id";
|
||||
|
||||
GET DIAGNOSTICS updated_count = ROW_COUNT;
|
||||
EXIT WHEN updated_count = 0;
|
||||
END LOOP;
|
||||
END $$;--> statement-breakpoint
|
||||
|
||||
DROP INDEX IF EXISTS "agent_config_revisions_remove_model_profiles_idx";--> statement-breakpoint
|
||||
|
||||
-- paperclip:migration-safety-ignore large-create-index-not-concurrently: This temporary partial index covers only rows with the retired JSON key and is dropped after the bounded cleanup.
|
||||
CREATE INDEX IF NOT EXISTS "issues_remove_model_profile_idx"
|
||||
ON "issues" USING btree ("id")
|
||||
WHERE "assignee_adapter_overrides" ? 'modelProfile';--> statement-breakpoint
|
||||
|
||||
DO $$
|
||||
DECLARE
|
||||
updated_count integer;
|
||||
BEGIN
|
||||
LOOP
|
||||
WITH batch AS MATERIALIZED (
|
||||
SELECT "id"
|
||||
FROM "issues"
|
||||
WHERE "assignee_adapter_overrides" ? 'modelProfile'
|
||||
ORDER BY "id"
|
||||
LIMIT 1000
|
||||
)
|
||||
UPDATE "issues" AS issue
|
||||
SET "assignee_adapter_overrides" = NULLIF(
|
||||
issue."assignee_adapter_overrides" - 'modelProfile',
|
||||
'{}'::jsonb
|
||||
)
|
||||
FROM batch
|
||||
WHERE issue."id" = batch."id";
|
||||
|
||||
GET DIAGNOSTICS updated_count = ROW_COUNT;
|
||||
EXIT WHEN updated_count = 0;
|
||||
END LOOP;
|
||||
END $$;--> statement-breakpoint
|
||||
|
||||
DROP INDEX IF EXISTS "issues_remove_model_profile_idx";
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -1639,6 +1639,13 @@
|
|||
"when": 1788198788171,
|
||||
"tag": "0235_heartbeat_run_event_sequence_uniqueness",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 236,
|
||||
"version": "7",
|
||||
"when": 1788283761224,
|
||||
"tag": "0236_remove_cheap_model_profiles",
|
||||
"breakpoints": true
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -167,13 +167,6 @@ const manifest: PaperclipPluginManifestV1 = {
|
|||
desiredSkills: WIKI_MANAGED_SKILL_CANONICAL_KEYS
|
||||
}
|
||||
},
|
||||
runtimeConfig: {
|
||||
modelProfiles: {
|
||||
cheap: {
|
||||
purpose: "classification, lint planning, index maintenance"
|
||||
}
|
||||
}
|
||||
},
|
||||
permissions: {
|
||||
pluginTools: [PLUGIN_ID]
|
||||
},
|
||||
|
|
|
|||
|
|
@ -5443,7 +5443,6 @@ function DistillationSettingsPanel({ context, settings }: { context: { companyId
|
|||
const counts = data?.counts ?? { cursors: 0, runningRuns: 0, failedRuns24h: 0, reviewRequired: 0 };
|
||||
const isConfigured = cursors.length > 0;
|
||||
const autoApplyRestriction = settings.distillationPolicy?.autoApplyRestriction ?? null;
|
||||
const [useCheapPath, setUseCheapPath] = useState(true);
|
||||
|
||||
const projectsCovered = useMemo(() => {
|
||||
const set = new Set<string>();
|
||||
|
|
@ -5463,7 +5462,6 @@ function DistillationSettingsPanel({ context, settings }: { context: { companyId
|
|||
try {
|
||||
await distillNow({
|
||||
companyId: context.companyId,
|
||||
useCheapModelProfile: useCheapPath,
|
||||
idempotencyKey: `manual:company:${Date.now()}`,
|
||||
});
|
||||
toast({
|
||||
|
|
@ -5515,7 +5513,6 @@ function DistillationSettingsPanel({ context, settings }: { context: { companyId
|
|||
companyId: context.companyId,
|
||||
projectId: target.projectId ?? undefined,
|
||||
rootIssueId: target.rootIssueId ?? undefined,
|
||||
useCheapModelProfile: useCheapPath,
|
||||
});
|
||||
toast({ tone: "success", title: "Backfill queued", body: target.projectName ?? target.rootIssueIdentifier ?? "Selected scope" });
|
||||
overview.refresh();
|
||||
|
|
@ -5607,8 +5604,7 @@ function DistillationSettingsPanel({ context, settings }: { context: { companyId
|
|||
</div>
|
||||
</div>
|
||||
<Tiny style={{ marginTop: 6 }}>
|
||||
Distillation runs on the assigned Wiki Maintainer agent and writes only into the default
|
||||
space. Use the cheap path option when the agent exposes a cheap model profile.
|
||||
Distillation runs on the assigned Wiki Maintainer agent and writes only into the default space.
|
||||
</Tiny>
|
||||
</Callout>
|
||||
|
||||
|
|
@ -5670,13 +5666,6 @@ function DistillationSettingsPanel({ context, settings }: { context: { companyId
|
|||
: "No maintainer agent resolved"}
|
||||
</div>
|
||||
</SettingField>
|
||||
<SettingField label="Cheap path" hint="When enabled, manual distill and backfill operation issues request assigneeAdapterOverrides.modelProfile = cheap.">
|
||||
<CheckboxRow
|
||||
label="Request the assigned agent's cheap model profile for distillation tasks"
|
||||
checked={useCheapPath}
|
||||
onChange={setUseCheapPath}
|
||||
/>
|
||||
</SettingField>
|
||||
</div>
|
||||
</CardBody>
|
||||
</Card>
|
||||
|
|
|
|||
|
|
@ -260,7 +260,6 @@ type OperationInput = {
|
|||
operationType: "ingest" | "query" | "lint" | "file-as-page" | "index" | "distill" | "backfill";
|
||||
title?: string | null;
|
||||
prompt?: string | null;
|
||||
useCheapModelProfile?: boolean;
|
||||
};
|
||||
|
||||
type OperationSpaceContext = {
|
||||
|
|
@ -2354,7 +2353,6 @@ export async function createOperationIssue(ctx: PluginContext, input: OperationI
|
|||
status: "todo",
|
||||
priority: input.operationType === "query" ? "medium" : "low",
|
||||
assigneeAgentId: assignableAgentId,
|
||||
assigneeAdapterOverrides: input.useCheapModelProfile ? { modelProfile: "cheap" } : null,
|
||||
billingCode: operationBillingCode(wikiId, space),
|
||||
surfaceVisibility: "plugin_operation",
|
||||
originKind: `${OPERATION_ORIGIN_KIND}:${input.operationType}` as PluginIssueOriginKind,
|
||||
|
|
|
|||
|
|
@ -296,7 +296,6 @@ const plugin = definePlugin({
|
|||
operationType,
|
||||
title: stringField(params.title),
|
||||
prompt: stringField(params.prompt),
|
||||
useCheapModelProfile: params.useCheapModelProfile === true,
|
||||
});
|
||||
});
|
||||
|
||||
|
|
@ -447,7 +446,6 @@ const plugin = definePlugin({
|
|||
spaceSlug,
|
||||
operationType: "backfill",
|
||||
title: scope.rootIssueId ? "Backfill Paperclip root issue wiki history" : "Backfill Paperclip project wiki history",
|
||||
useCheapModelProfile: params.useCheapModelProfile === true,
|
||||
prompt: [
|
||||
"Backfill LLM Wiki distillation was queued from a per-space Paperclip ingestion profile.",
|
||||
scope.projectId ? `Project ID: ${scope.projectId}` : null,
|
||||
|
|
@ -618,7 +616,6 @@ const plugin = definePlugin({
|
|||
: projectId
|
||||
? "Distill Paperclip project into wiki"
|
||||
: "Distill Paperclip changes into wiki",
|
||||
useCheapModelProfile: params.useCheapModelProfile === true,
|
||||
prompt: buildManualDistillPrompt({ companyId, projectId, rootIssueId }),
|
||||
});
|
||||
return { status: "queued", workItem, operation };
|
||||
|
|
@ -660,7 +657,6 @@ const plugin = definePlugin({
|
|||
spaceSlug,
|
||||
operationType: "backfill",
|
||||
title: rootIssueId ? "Backfill Paperclip root issue wiki history" : "Backfill Paperclip project wiki history",
|
||||
useCheapModelProfile: params.useCheapModelProfile === true,
|
||||
prompt: [
|
||||
"Backfill LLM Wiki distillation requested for a bounded Paperclip source window.",
|
||||
projectId ? `Project ID: ${projectId}` : null,
|
||||
|
|
|
|||
|
|
@ -1213,7 +1213,7 @@ Duplicate headings receive stable suffixes.
|
|||
expect(markup).not.toContain("Permissions are stored but not enforced");
|
||||
});
|
||||
|
||||
it("renders distillation settings with assigned-agent model selection and cheap path without budget controls", () => {
|
||||
it("renders distillation settings with assigned-agent execution without budget controls", () => {
|
||||
mockPathname = "/PAP/wiki/settings/distillation";
|
||||
mockDistillationOverviewData = {
|
||||
counts: { cursors: 1, runningRuns: 0, failedRuns24h: 0, reviewRequired: 0 },
|
||||
|
|
@ -1236,8 +1236,6 @@ Duplicate headings receive stable suffixes.
|
|||
expect(markup).toContain("Agent execution");
|
||||
expect(markup).toContain("Assigned maintainer");
|
||||
expect(markup).toContain("Wiki Maintainer · claude local");
|
||||
expect(markup).toContain("Cheap path");
|
||||
expect(markup).toContain("assigneeAdapterOverrides.modelProfile = cheap");
|
||||
expect(markup).toContain("All sections — apply when source hash matches and confidence");
|
||||
expect(markup).not.toContain("Per-task budget");
|
||||
expect(markup).not.toContain("Project total budget");
|
||||
|
|
@ -2279,12 +2277,11 @@ Duplicate headings receive stable suffixes.
|
|||
await plugin.definition.setup(harness.ctx);
|
||||
const result = await harness.performAction<{
|
||||
status: string;
|
||||
operation: { issue: { originKind: string; billingCode: string | null; assigneeAgentId: string | null; assigneeAdapterOverrides: { modelProfile?: string } | null; description: string | null } };
|
||||
operation: { issue: { originKind: string; billingCode: string | null; assigneeAgentId: string | null; assigneeAdapterOverrides: Record<string, unknown> | null; description: string | null } };
|
||||
workItem: { kind: string; workItemId: string };
|
||||
}>("distill-paperclip-now", {
|
||||
companyId: COMPANY_ID,
|
||||
autoApply: false,
|
||||
useCheapModelProfile: true,
|
||||
includeSupportingPages: false,
|
||||
});
|
||||
|
||||
|
|
@ -2293,7 +2290,7 @@ Duplicate headings receive stable suffixes.
|
|||
expect(result.operation.issue.originKind).toBe(`${OPERATION_ORIGIN_KIND}:distill`);
|
||||
expect(result.operation.issue.billingCode).toBe("plugin-llm-wiki:default");
|
||||
expect(result.operation.issue.assigneeAgentId).toBe(wikiMaintainerAgent().id);
|
||||
expect(result.operation.issue.assigneeAdapterOverrides).toEqual({ modelProfile: "cheap" });
|
||||
expect(result.operation.issue.assigneeAdapterOverrides).toBeNull();
|
||||
expect(result.operation.issue.description).toContain("Prompt source: LLM Wiki plugin action `distill-paperclip-now`");
|
||||
expect(result.operation.issue.description).toContain(`Required skill: use the installed \`${PAPERCLIP_DISTILL_SKILL_KEY}\` skill`);
|
||||
expect(result.operation.issue.description).toContain("Do not hardcode a single project");
|
||||
|
|
|
|||
|
|
@ -91,9 +91,6 @@ export const ADAPTER_AGNOSTIC_KEYS = [
|
|||
] as const;
|
||||
export type AdapterAgnosticKey = (typeof ADAPTER_AGNOSTIC_KEYS)[number];
|
||||
|
||||
export const MODEL_PROFILE_KEYS = ["cheap"] as const;
|
||||
export type ModelProfileKey = (typeof MODEL_PROFILE_KEYS)[number];
|
||||
|
||||
export const AGENT_ICON_NAMES = [
|
||||
"bot",
|
||||
"cpu",
|
||||
|
|
|
|||
|
|
@ -364,7 +364,6 @@ export {
|
|||
AGENT_DEFAULT_MAX_CONCURRENT_RUNS,
|
||||
WORKSPACE_BRANCH_ROUTINE_VARIABLE,
|
||||
ADAPTER_AGNOSTIC_KEYS,
|
||||
MODEL_PROFILE_KEYS,
|
||||
AGENT_ICON_NAMES,
|
||||
PROJECT_ICON_NAMES,
|
||||
ISSUE_STATUSES,
|
||||
|
|
@ -562,7 +561,6 @@ export {
|
|||
type AgentAdapterType,
|
||||
type AgentRole,
|
||||
type AdapterAgnosticKey,
|
||||
type ModelProfileKey,
|
||||
type AgentIconName,
|
||||
type ProjectIconName,
|
||||
type IssueStatus,
|
||||
|
|
@ -1837,6 +1835,7 @@ export {
|
|||
agentSkillSyncSchema,
|
||||
type AgentSkillSync,
|
||||
createAgentSchema,
|
||||
agentRuntimeConfigSchema,
|
||||
builtInAgentEmptyMutationSchema,
|
||||
builtInAgentProvisionSchema,
|
||||
builtInAgentResetSchema,
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
import type {
|
||||
AgentAdapterType,
|
||||
ModelProfileKey,
|
||||
PauseReason,
|
||||
AgentRole,
|
||||
AgentStatus,
|
||||
|
|
@ -23,15 +22,7 @@ export interface AgentPermissions extends Record<string, unknown> {
|
|||
authorizationPolicy?: TrustAuthorizationPolicy;
|
||||
}
|
||||
|
||||
export interface AgentModelProfileConfig {
|
||||
enabled?: boolean;
|
||||
label?: string;
|
||||
adapterConfig: Record<string, unknown>;
|
||||
}
|
||||
|
||||
export interface AgentRuntimeConfig extends Record<string, unknown> {
|
||||
modelProfiles?: Partial<Record<ModelProfileKey, AgentModelProfileConfig>>;
|
||||
}
|
||||
export type AgentRuntimeConfig = Record<string, unknown>;
|
||||
|
||||
export type AgentInstructionsBundleMode = "managed" | "external";
|
||||
|
||||
|
|
|
|||
|
|
@ -278,7 +278,6 @@ export type {
|
|||
AgentChainOfCommandEntry,
|
||||
AgentDetail,
|
||||
ClearAgentErrorResponse,
|
||||
AgentModelProfileConfig,
|
||||
AgentPermissions,
|
||||
AgentRuntimeConfig,
|
||||
AgentInstructionsBundleMode,
|
||||
|
|
|
|||
|
|
@ -23,7 +23,6 @@ import type {
|
|||
IssueRecoveryActionOwnerType,
|
||||
IssueRecoveryActionStatus,
|
||||
IssueWorkMode,
|
||||
ModelProfileKey,
|
||||
IssueThreadInteractionContinuationPolicy,
|
||||
IssueThreadInteractionCanonicalResolverPolicy,
|
||||
IssueThreadInteractionEffectiveResolverPolicySource,
|
||||
|
|
@ -89,7 +88,6 @@ export interface IssueLabel {
|
|||
}
|
||||
|
||||
export interface IssueAssigneeAdapterOverrides {
|
||||
modelProfile?: ModelProfileKey;
|
||||
adapterConfig?: Record<string, unknown>;
|
||||
useProjectWorkspace?: boolean;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -57,23 +57,19 @@ export const createAgentInstructionsBundleSchema = z.object({
|
|||
}),
|
||||
});
|
||||
|
||||
const agentModelProfileConfigSchema = z.object({
|
||||
enabled: z.boolean().optional(),
|
||||
label: z.string().trim().min(1).optional(),
|
||||
// Disabled profiles created before model-profile editing may not have an
|
||||
// adapter payload yet. Keep them valid so unrelated runtime settings (such
|
||||
// as debug capture) can be updated without fabricating model configuration.
|
||||
adapterConfig: adapterConfigSchema.optional().default({}),
|
||||
}).strict();
|
||||
|
||||
export const agentRuntimeConfigSchema = z.object({
|
||||
modelProfiles: z.object({
|
||||
cheap: agentModelProfileConfigSchema.optional(),
|
||||
}).strict().optional(),
|
||||
debug: z.object({
|
||||
providerTrace: z.literal("raw").optional(),
|
||||
}).strict().optional(),
|
||||
}).catchall(z.unknown());
|
||||
}).catchall(z.unknown()).superRefine((value, ctx) => {
|
||||
if (Object.prototype.hasOwnProperty.call(value, "modelProfiles")) {
|
||||
ctx.addIssue({
|
||||
code: z.ZodIssueCode.custom,
|
||||
path: ["modelProfiles"],
|
||||
message: "runtimeConfig.modelProfiles is no longer supported",
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
export const createAgentSchema = z.object({
|
||||
name: z.string().min(1),
|
||||
|
|
|
|||
|
|
@ -458,29 +458,19 @@ describe("issue validators", () => {
|
|||
expect(parsed.requestDepth).toBe(MAX_ISSUE_REQUEST_DEPTH);
|
||||
});
|
||||
|
||||
it("accepts the cheap model profile in issue assignee adapter overrides", () => {
|
||||
const parsed = createIssueSchema.parse({
|
||||
title: "Run a cheap heartbeat",
|
||||
it("rejects retired model profiles in issue assignee adapter overrides", () => {
|
||||
const parsed = createIssueSchema.safeParse({
|
||||
title: "Run a heartbeat",
|
||||
assigneeAdapterOverrides: {
|
||||
modelProfile: "cheap",
|
||||
},
|
||||
});
|
||||
|
||||
expect(parsed.assigneeAdapterOverrides?.modelProfile).toBe("cheap");
|
||||
});
|
||||
|
||||
it("rejects unknown issue model profile keys", () => {
|
||||
const parsed = updateIssueSchema.safeParse({
|
||||
assigneeAdapterOverrides: {
|
||||
modelProfile: "fast",
|
||||
},
|
||||
});
|
||||
|
||||
expect(parsed.success).toBe(false);
|
||||
});
|
||||
|
||||
it("validates agent runtime cheap model profile config without rejecting other runtime fields", () => {
|
||||
const parsed = createAgentSchema.parse({
|
||||
it("rejects retired model profiles in agent runtime config", () => {
|
||||
const parsed = createAgentSchema.safeParse({
|
||||
name: "Coder",
|
||||
adapterType: "codex_local",
|
||||
runtimeConfig: {
|
||||
|
|
@ -497,47 +487,6 @@ describe("issue validators", () => {
|
|||
},
|
||||
});
|
||||
|
||||
expect(parsed.runtimeConfig.modelProfiles?.cheap?.adapterConfig).toEqual({
|
||||
model: "gpt-5.3-codex-spark",
|
||||
});
|
||||
expect(parsed.runtimeConfig.heartbeat).toEqual({ enabled: true });
|
||||
});
|
||||
|
||||
it("validates cheap model profile env bindings like top-level adapter config", () => {
|
||||
const parsed = createAgentSchema.safeParse({
|
||||
name: "Coder",
|
||||
adapterType: "codex_local",
|
||||
runtimeConfig: {
|
||||
modelProfiles: {
|
||||
cheap: {
|
||||
adapterConfig: {
|
||||
env: {
|
||||
API_TOKEN: 123,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
expect(parsed.success).toBe(false);
|
||||
});
|
||||
|
||||
it("rejects unknown agent runtime model profile keys", () => {
|
||||
const parsed = createAgentSchema.safeParse({
|
||||
name: "Coder",
|
||||
adapterType: "codex_local",
|
||||
runtimeConfig: {
|
||||
modelProfiles: {
|
||||
fast: {
|
||||
adapterConfig: {
|
||||
model: "gpt-5-mini",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
expect(parsed.success).toBe(false);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -32,7 +32,6 @@ import {
|
|||
ISSUE_THREAD_INTERACTION_RESOLVER_POLICY_PROVENANCES,
|
||||
ISSUE_THREAD_INTERACTION_STATUSES,
|
||||
ISSUE_WATCHDOG_DISCOVERY_KINDS,
|
||||
MODEL_PROFILE_KEYS,
|
||||
REQUEST_CHECKBOX_CONFIRMATION_OPTION_LIMIT,
|
||||
REQUEST_ITEM_VERDICTS_ITEM_LIMIT,
|
||||
} from "../constants.js";
|
||||
|
|
@ -222,7 +221,6 @@ export const issueExecutionWorkspaceSettingsSchema = z
|
|||
|
||||
export const issueAssigneeAdapterOverridesSchema = z
|
||||
.object({
|
||||
modelProfile: z.enum(MODEL_PROFILE_KEYS).optional(),
|
||||
adapterConfig: z.record(z.string(), z.unknown()).optional(),
|
||||
useProjectWorkspace: z.boolean().optional(),
|
||||
})
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@ import {
|
|||
findActiveServerAdapter,
|
||||
findServerAdapter,
|
||||
listAdapterModels,
|
||||
listAdapterModelProfiles,
|
||||
registerServerAdapter,
|
||||
requireServerAdapter,
|
||||
unregisterServerAdapter,
|
||||
|
|
@ -62,31 +61,6 @@ describe("server adapter registry", () => {
|
|||
]);
|
||||
});
|
||||
|
||||
it("exposes adapter model profiles when adapters declare them", async () => {
|
||||
const adapterWithProfiles: ServerAdapterModule = {
|
||||
...externalAdapter,
|
||||
modelProfiles: [
|
||||
{
|
||||
key: "cheap",
|
||||
label: "Cheap",
|
||||
adapterConfig: { model: "external-mini" },
|
||||
source: "adapter_default",
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
registerServerAdapter(adapterWithProfiles);
|
||||
|
||||
expect(await listAdapterModelProfiles("external_test")).toEqual([
|
||||
{
|
||||
key: "cheap",
|
||||
label: "Cheap",
|
||||
adapterConfig: { model: "external-mini" },
|
||||
source: "adapter_default",
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
it("removes external adapters when unregistered", () => {
|
||||
registerServerAdapter(externalAdapter);
|
||||
|
||||
|
|
@ -275,45 +249,6 @@ describe("server adapter registry", () => {
|
|||
});
|
||||
});
|
||||
|
||||
it("built-in local adapters declare cheap model profile defaults where supported", async () => {
|
||||
await expect(listAdapterModelProfiles("claude_local")).resolves.toEqual([
|
||||
expect.objectContaining({
|
||||
key: "cheap",
|
||||
adapterConfig: expect.objectContaining({ model: "claude-sonnet-4-6" }),
|
||||
source: "adapter_default",
|
||||
}),
|
||||
]);
|
||||
await expect(listAdapterModelProfiles("codex_local")).resolves.toEqual([
|
||||
expect.objectContaining({
|
||||
key: "cheap",
|
||||
adapterConfig: {},
|
||||
source: "adapter_default",
|
||||
}),
|
||||
]);
|
||||
await expect(listAdapterModelProfiles("gemini_local")).resolves.toEqual([
|
||||
expect.objectContaining({
|
||||
key: "cheap",
|
||||
adapterConfig: expect.objectContaining({ model: "gemini-2.5-flash-lite" }),
|
||||
source: "adapter_default",
|
||||
}),
|
||||
]);
|
||||
await expect(listAdapterModelProfiles("opencode_local")).resolves.toEqual([
|
||||
expect.objectContaining({
|
||||
key: "cheap",
|
||||
adapterConfig: expect.objectContaining({ model: "openai/gpt-5.1-codex-mini" }),
|
||||
source: "adapter_default",
|
||||
}),
|
||||
]);
|
||||
await expect(listAdapterModelProfiles("cursor")).resolves.toEqual([
|
||||
expect.objectContaining({
|
||||
key: "cheap",
|
||||
adapterConfig: expect.objectContaining({ model: "gpt-5.1-codex-mini" }),
|
||||
source: "adapter_default",
|
||||
}),
|
||||
]);
|
||||
await expect(listAdapterModelProfiles("pi_local")).resolves.toEqual([]);
|
||||
});
|
||||
|
||||
it("wraps built-in npm runtime installs with the sandbox-aware install helper", () => {
|
||||
const expectedClaudeInstall = `if ! command -v 'claude' >/dev/null 2>&1; then ${buildSandboxNpmInstallCommand("@anthropic-ai/claude-code")}; fi`;
|
||||
const expectedCodexInstall = `if ! command -v 'codex' >/dev/null 2>&1; then ${buildSandboxNpmInstallCommand("@openai/codex")}; fi`;
|
||||
|
|
|
|||
|
|
@ -164,7 +164,6 @@ describe("adapter routes", () => {
|
|||
disabled: false,
|
||||
capabilities: {
|
||||
supportsInstructionsBundle: false,
|
||||
supportsModelProfiles: true,
|
||||
},
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -434,9 +434,7 @@ describe.sequential("agent permission routes", () => {
|
|||
env: { PAPERCLIP_API_KEY: "secret-test-key" },
|
||||
},
|
||||
runtimeConfig: {
|
||||
modelProfiles: {
|
||||
default: { enabled: true, adapterConfig: { model: "openai/gpt-5.4-mini" } },
|
||||
},
|
||||
heartbeat: { enabled: false },
|
||||
},
|
||||
});
|
||||
|
||||
|
|
@ -456,9 +454,7 @@ describe.sequential("agent permission routes", () => {
|
|||
env: { PAPERCLIP_API_KEY: "secret-test-key" },
|
||||
});
|
||||
expect(res.body.runtimeConfig).toMatchObject({
|
||||
modelProfiles: {
|
||||
default: { enabled: true, adapterConfig: { model: "openai/gpt-5.4-mini" } },
|
||||
},
|
||||
heartbeat: { enabled: false },
|
||||
});
|
||||
expect(res.body.permissions).toMatchObject({ trustPreset: LOW_TRUST_REVIEW_PRESET });
|
||||
}, 20_000);
|
||||
|
|
@ -693,165 +689,6 @@ describe.sequential("agent permission routes", () => {
|
|||
expect(mockLogActivity).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("blocks agent-authenticated self-updates that set cheap-profile host-executed workspace commands", async () => {
|
||||
mockAgentService.getById.mockResolvedValue({
|
||||
...baseAgent,
|
||||
adapterType: "codex_local",
|
||||
});
|
||||
|
||||
const app = await createApp({
|
||||
type: "agent",
|
||||
agentId,
|
||||
companyId,
|
||||
source: "agent_key",
|
||||
runId: "run-1",
|
||||
});
|
||||
|
||||
const res = await requestApp(app, (baseUrl) => request(baseUrl)
|
||||
.patch(`/api/agents/${agentId}`)
|
||||
.send({
|
||||
runtimeConfig: {
|
||||
modelProfiles: {
|
||||
cheap: {
|
||||
adapterConfig: {
|
||||
workspaceStrategy: {
|
||||
type: "git_worktree",
|
||||
provisionCommand: "touch /tmp/paperclip-rce",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}));
|
||||
|
||||
expect(res.status).toBe(403);
|
||||
expect(res.body.error).toContain("host-executed workspace commands");
|
||||
expect(res.body.error).toContain(
|
||||
"runtimeConfig.modelProfiles.cheap.adapterConfig.workspaceStrategy.provisionCommand",
|
||||
);
|
||||
expect(mockLogActivity).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("allows board updates that set cheap-profile workspace commands", async () => {
|
||||
mockAgentService.getById.mockResolvedValue({
|
||||
...baseAgent,
|
||||
adapterType: "codex_local",
|
||||
});
|
||||
|
||||
const app = await createApp({
|
||||
type: "board",
|
||||
userId: "board-user",
|
||||
source: "local_implicit",
|
||||
isInstanceAdmin: true,
|
||||
companyIds: [companyId],
|
||||
});
|
||||
|
||||
const runtimeConfig = {
|
||||
modelProfiles: {
|
||||
cheap: {
|
||||
adapterConfig: {
|
||||
workspaceStrategy: {
|
||||
type: "git_worktree",
|
||||
provisionCommand: "bash ./scripts/provision-worktree.sh",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
const res = await requestApp(app, (baseUrl) => request(baseUrl)
|
||||
.patch(`/api/agents/${agentId}`)
|
||||
.send({ runtimeConfig }));
|
||||
|
||||
expect(res.status, JSON.stringify(res.body)).toBe(200);
|
||||
expect(mockAgentService.update).toHaveBeenCalledWith(
|
||||
agentId,
|
||||
expect.objectContaining({ runtimeConfig }),
|
||||
expect.anything(),
|
||||
);
|
||||
expect(mockLogActivity).toHaveBeenCalledWith(expect.anything(), expect.objectContaining({
|
||||
action: "agent.updated",
|
||||
}));
|
||||
});
|
||||
|
||||
it("normalizes cheap-profile env bindings through the adapter config secret pipeline", async () => {
|
||||
mockAgentService.getById.mockResolvedValue({
|
||||
...baseAgent,
|
||||
adapterType: "codex_local",
|
||||
});
|
||||
mockSecretService.normalizeAdapterConfigForPersistence.mockImplementation(async (_companyId, config) => ({
|
||||
...config,
|
||||
env: {
|
||||
API_TOKEN: {
|
||||
type: "secret_ref",
|
||||
secretId: "33333333-3333-4333-8333-333333333333",
|
||||
version: "latest",
|
||||
},
|
||||
},
|
||||
}));
|
||||
|
||||
const app = await createApp({
|
||||
type: "board",
|
||||
userId: "board-user",
|
||||
source: "local_implicit",
|
||||
isInstanceAdmin: true,
|
||||
companyIds: [companyId],
|
||||
});
|
||||
|
||||
const res = await requestApp(app, (baseUrl) => request(baseUrl)
|
||||
.patch(`/api/agents/${agentId}`)
|
||||
.send({
|
||||
runtimeConfig: {
|
||||
modelProfiles: {
|
||||
cheap: {
|
||||
adapterConfig: {
|
||||
model: "gpt-5.3-codex-spark",
|
||||
env: {
|
||||
API_TOKEN: {
|
||||
type: "secret_ref",
|
||||
secretId: "33333333-3333-4333-8333-333333333333",
|
||||
version: "latest",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}));
|
||||
|
||||
expect(res.status, JSON.stringify(res.body)).toBe(200);
|
||||
expect(mockSecretService.normalizeAdapterConfigForPersistence).toHaveBeenCalledWith(
|
||||
companyId,
|
||||
expect.objectContaining({
|
||||
model: "gpt-5.3-codex-spark",
|
||||
env: expect.any(Object),
|
||||
}),
|
||||
{ strictMode: false, adapterType: "codex_local" },
|
||||
);
|
||||
expect(mockAgentService.update).toHaveBeenCalledWith(
|
||||
agentId,
|
||||
expect.objectContaining({
|
||||
runtimeConfig: {
|
||||
modelProfiles: {
|
||||
cheap: {
|
||||
adapterConfig: {
|
||||
model: "gpt-5.3-codex-spark",
|
||||
env: {
|
||||
API_TOKEN: {
|
||||
type: "secret_ref",
|
||||
secretId: "33333333-3333-4333-8333-333333333333",
|
||||
version: "latest",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}),
|
||||
expect.anything(),
|
||||
);
|
||||
});
|
||||
|
||||
it("blocks agent-authenticated self-updates that set instructions bundle roots", async () => {
|
||||
const app = await createApp({
|
||||
type: "agent",
|
||||
|
|
@ -1102,81 +939,12 @@ describe.sequential("agent permission routes", () => {
|
|||
intervalSec: 3600,
|
||||
maxConcurrentRuns: 20,
|
||||
},
|
||||
modelProfiles: {
|
||||
cheap: { enabled: false },
|
||||
},
|
||||
},
|
||||
}),
|
||||
{ claudeLogin: { storedSessionId: null, ownerUserId: "board-user", applyExistingWithoutClaim: false } },
|
||||
);
|
||||
});
|
||||
|
||||
it("creates agents when optional adapter model profile discovery fails", async () => {
|
||||
const { registerServerAdapter, unregisterServerAdapter } = await import("../adapters/index.js");
|
||||
registerServerAdapter({
|
||||
type: "failing_profile_discovery",
|
||||
execute: async () => ({ exitCode: 0, signal: null, timedOut: false }),
|
||||
testEnvironment: async () => ({
|
||||
adapterType: "failing_profile_discovery",
|
||||
status: "pass",
|
||||
checks: [],
|
||||
testedAt: new Date(0).toISOString(),
|
||||
}),
|
||||
listModelProfiles: async () => {
|
||||
throw new Error("profile discovery unavailable");
|
||||
},
|
||||
});
|
||||
|
||||
try {
|
||||
const app = await createApp({
|
||||
type: "board",
|
||||
userId: "board-user",
|
||||
source: "local_implicit",
|
||||
isInstanceAdmin: true,
|
||||
companyIds: [companyId],
|
||||
});
|
||||
|
||||
const res = await requestApp(app, (baseUrl) => request(baseUrl)
|
||||
.post(`/api/companies/${companyId}/agents`)
|
||||
.send({
|
||||
name: "Builder",
|
||||
role: "engineer",
|
||||
adapterType: "failing_profile_discovery",
|
||||
adapterConfig: {},
|
||||
runtimeConfig: {
|
||||
modelProfiles: {
|
||||
cheap: {
|
||||
enabled: true,
|
||||
adapterConfig: {},
|
||||
},
|
||||
},
|
||||
},
|
||||
}));
|
||||
|
||||
expect(res.status, JSON.stringify(res.body)).toBe(201);
|
||||
expect(mockAgentService.create).toHaveBeenCalledWith(
|
||||
companyId,
|
||||
expect.objectContaining({
|
||||
runtimeConfig: {
|
||||
heartbeat: {
|
||||
enabled: false,
|
||||
maxConcurrentRuns: 20,
|
||||
},
|
||||
modelProfiles: {
|
||||
cheap: {
|
||||
enabled: true,
|
||||
adapterConfig: {},
|
||||
},
|
||||
},
|
||||
},
|
||||
}),
|
||||
{ claudeLogin: { storedSessionId: null, ownerUserId: "board-user", applyExistingWithoutClaim: false } },
|
||||
);
|
||||
} finally {
|
||||
unregisterServerAdapter("failing_profile_discovery");
|
||||
}
|
||||
});
|
||||
|
||||
it("seeds opencode agent creation with the static default model without live discovery", async () => {
|
||||
mockEnsureOpenCodeModelConfiguredAndAvailable.mockRejectedValue(
|
||||
new Error("`opencode models` should not be called during creation"),
|
||||
|
|
@ -1284,9 +1052,6 @@ describe.sequential("agent permission routes", () => {
|
|||
intervalSec: 3600,
|
||||
maxConcurrentRuns: 20,
|
||||
},
|
||||
modelProfiles: {
|
||||
cheap: { enabled: false },
|
||||
},
|
||||
},
|
||||
}),
|
||||
{ claudeLogin: { storedSessionId: null, ownerUserId: "board-user", applyExistingWithoutClaim: false } },
|
||||
|
|
|
|||
|
|
@ -374,7 +374,6 @@ describe("approval routes idempotent retries", () => {
|
|||
it("blocks status-only recovery runs from creating approvals", async () => {
|
||||
const res = await request(await createAgentApp({
|
||||
contextSnapshot: {
|
||||
modelProfile: "cheap",
|
||||
recoveryIntent: "status_only",
|
||||
allowDeliverableWork: false,
|
||||
allowDocumentUpdates: false,
|
||||
|
|
@ -388,7 +387,7 @@ describe("approval routes idempotent retries", () => {
|
|||
});
|
||||
|
||||
expect(res.status, JSON.stringify(res.body)).toBe(403);
|
||||
expect(res.body.error).toContain("Cheap status-only recovery runs cannot create or modify approvals");
|
||||
expect(res.body.error).toContain("Status-only recovery runs cannot create or modify approvals");
|
||||
expect(mockApprovalService.create).not.toHaveBeenCalled();
|
||||
expect(mockIssueApprovalService.linkManyForApproval).not.toHaveBeenCalled();
|
||||
});
|
||||
|
|
@ -405,7 +404,6 @@ describe("approval routes idempotent retries", () => {
|
|||
|
||||
const res = await request(await createAgentApp({
|
||||
contextSnapshot: {
|
||||
modelProfile: "cheap",
|
||||
recoveryIntent: "status_only",
|
||||
allowDeliverableWork: false,
|
||||
allowDocumentUpdates: false,
|
||||
|
|
@ -416,7 +414,7 @@ describe("approval routes idempotent retries", () => {
|
|||
.send({ payload: { title: "Retry" } });
|
||||
|
||||
expect(res.status, JSON.stringify(res.body)).toBe(403);
|
||||
expect(res.body.error).toContain("Cheap status-only recovery runs cannot create or modify approvals");
|
||||
expect(res.body.error).toContain("Status-only recovery runs cannot create or modify approvals");
|
||||
expect(mockApprovalService.resubmit).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
|
|
@ -432,7 +430,6 @@ describe("approval routes idempotent retries", () => {
|
|||
|
||||
const res = await request(await createAgentApp({
|
||||
contextSnapshot: {
|
||||
modelProfile: "cheap",
|
||||
recoveryIntent: "status_only",
|
||||
allowDeliverableWork: false,
|
||||
allowDocumentUpdates: false,
|
||||
|
|
@ -443,7 +440,7 @@ describe("approval routes idempotent retries", () => {
|
|||
.send({ body: "please approve" });
|
||||
|
||||
expect(res.status, JSON.stringify(res.body)).toBe(403);
|
||||
expect(res.body.error).toContain("Cheap status-only recovery runs cannot create or modify approvals");
|
||||
expect(res.body.error).toContain("Status-only recovery runs cannot create or modify approvals");
|
||||
expect(mockApprovalService.addComment).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1209,8 +1209,6 @@ describeEmbeddedPostgres("built-in agents", () => {
|
|||
featureKeys: ["summarizer"],
|
||||
});
|
||||
|
||||
expect(state.agent?.runtimeConfig).not.toHaveProperty("modelProfiles.cheap");
|
||||
|
||||
expect(state.resources.map((resource) => [resource.resourceKind, resource.stockStatus])).toEqual([
|
||||
["instructions", "stock_current"],
|
||||
["skill", "stock_current"],
|
||||
|
|
@ -1266,24 +1264,6 @@ describeEmbeddedPostgres("built-in agents", () => {
|
|||
});
|
||||
});
|
||||
|
||||
it("preserves an operator-overridden cheap summariser model across reconcile", async () => {
|
||||
const companyId = await seedCompany();
|
||||
const builtIns = builtInAgentService(db);
|
||||
const created = await builtIns.ensure(companyId, "summarizer");
|
||||
|
||||
// Operator overrides the cheap lane with a provider-specific low-cost model.
|
||||
await agentService(db).update(created.agentId!, {
|
||||
runtimeConfig: {
|
||||
modelProfiles: { cheap: { enabled: true, label: "Cheap", adapterConfig: { model: "haiku-cheap" } } },
|
||||
},
|
||||
}, { allowBuiltInAgentMetadata: true });
|
||||
|
||||
const reconciled = await builtIns.ensure(companyId, "summarizer");
|
||||
expect(reconciled.agent?.runtimeConfig).toMatchObject({
|
||||
modelProfiles: { cheap: { adapterConfig: { model: "haiku-cheap" } } },
|
||||
});
|
||||
});
|
||||
|
||||
it("restores Summarizer instruction drift on reset", async () => {
|
||||
const companyId = await seedCompany();
|
||||
const builtIns = builtInAgentService(db);
|
||||
|
|
|
|||
|
|
@ -62,7 +62,6 @@ vi.mock("../adapters/index.js", () => ({
|
|||
execute: adapterExecute,
|
||||
supportsLocalAgentJwt: false,
|
||||
}),
|
||||
listAdapterModelProfiles: async () => [],
|
||||
runningProcesses: new Map(),
|
||||
}));
|
||||
|
||||
|
|
|
|||
|
|
@ -2014,8 +2014,8 @@ describeEmbeddedPostgres("heartbeat comment wake batching", () => {
|
|||
expect(payloads).toHaveLength(2);
|
||||
expect(runs[1]?.contextSnapshot).toMatchObject({
|
||||
retryReason: "missing_issue_comment",
|
||||
modelProfile: "cheap",
|
||||
});
|
||||
expect(runs[1]?.contextSnapshot).not.toHaveProperty("modelProfile");
|
||||
} finally {
|
||||
gateway.releaseFirstWait();
|
||||
await gateway.close();
|
||||
|
|
@ -2218,7 +2218,7 @@ describeEmbeddedPostgres("heartbeat comment wake batching", () => {
|
|||
),
|
||||
);
|
||||
expect(missingCommentRetries).toHaveLength(1);
|
||||
expect(missingCommentRetries[0]?.payload).toMatchObject({ modelProfile: "cheap" });
|
||||
expect(missingCommentRetries[0]?.payload).not.toHaveProperty("modelProfile");
|
||||
} finally {
|
||||
gateway.releaseFirstWait();
|
||||
await gateway.close();
|
||||
|
|
|
|||
|
|
@ -1,157 +0,0 @@
|
|||
import { describe, expect, it } from "vitest";
|
||||
import {
|
||||
listAdapterModelProfiles,
|
||||
type AdapterModelProfileDefinition,
|
||||
} from "../adapters/index.js";
|
||||
import {
|
||||
mergeModelProfileAdapterConfig,
|
||||
normalizeModelProfileWakeContext,
|
||||
resolveModelProfileApplication,
|
||||
isConfigurationIncompleteFailedRun,
|
||||
} from "../services/heartbeat.ts";
|
||||
|
||||
const cheapProfile: AdapterModelProfileDefinition = {
|
||||
key: "cheap",
|
||||
label: "Cheap",
|
||||
adapterConfig: {
|
||||
model: "adapter-cheap",
|
||||
modelReasoningEffort: "low",
|
||||
},
|
||||
source: "adapter_default",
|
||||
};
|
||||
|
||||
describe("heartbeat model profile application", () => {
|
||||
it("keeps Codex on its primary model when cheap has no explicit model override", async () => {
|
||||
const modelProfile = resolveModelProfileApplication({
|
||||
adapterModelProfiles: await listAdapterModelProfiles("codex_local"),
|
||||
agentRuntimeConfig: {},
|
||||
issueModelProfile: "cheap",
|
||||
contextSnapshot: {},
|
||||
});
|
||||
|
||||
const merged = mergeModelProfileAdapterConfig({
|
||||
baseConfig: { model: "primary" },
|
||||
modelProfile,
|
||||
issueAdapterConfig: null,
|
||||
});
|
||||
|
||||
expect(modelProfile).toMatchObject({
|
||||
requested: "cheap",
|
||||
requestedBy: "issue_override",
|
||||
applied: "cheap",
|
||||
configSource: "adapter_default",
|
||||
fallbackReason: null,
|
||||
adapterConfig: {},
|
||||
});
|
||||
expect(merged).toEqual({ model: "primary" });
|
||||
});
|
||||
|
||||
it("applies cheap profile patches before explicit issue adapter config overrides", () => {
|
||||
const modelProfile = resolveModelProfileApplication({
|
||||
adapterModelProfiles: [cheapProfile],
|
||||
agentRuntimeConfig: {},
|
||||
issueModelProfile: "cheap",
|
||||
contextSnapshot: {},
|
||||
});
|
||||
|
||||
const merged = mergeModelProfileAdapterConfig({
|
||||
baseConfig: {
|
||||
model: "primary",
|
||||
modelReasoningEffort: "high",
|
||||
approvalPolicy: "strict",
|
||||
},
|
||||
modelProfile,
|
||||
issueAdapterConfig: {
|
||||
model: "issue-explicit",
|
||||
},
|
||||
});
|
||||
|
||||
expect(modelProfile).toMatchObject({
|
||||
requested: "cheap",
|
||||
requestedBy: "issue_override",
|
||||
applied: "cheap",
|
||||
configSource: "adapter_default",
|
||||
fallbackReason: null,
|
||||
});
|
||||
expect(merged).toEqual({
|
||||
model: "issue-explicit",
|
||||
modelReasoningEffort: "low",
|
||||
approvalPolicy: "strict",
|
||||
});
|
||||
});
|
||||
|
||||
it("lets agent runtime profile config customize adapter defaults", () => {
|
||||
const modelProfile = resolveModelProfileApplication({
|
||||
adapterModelProfiles: [cheapProfile],
|
||||
agentRuntimeConfig: {
|
||||
modelProfiles: {
|
||||
cheap: {
|
||||
adapterConfig: {
|
||||
model: "agent-cheap",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
issueModelProfile: null,
|
||||
contextSnapshot: { modelProfile: "cheap" },
|
||||
});
|
||||
|
||||
expect(modelProfile).toMatchObject({
|
||||
requested: "cheap",
|
||||
requestedBy: "wake_context",
|
||||
applied: "cheap",
|
||||
configSource: "agent_runtime",
|
||||
adapterConfig: {
|
||||
model: "agent-cheap",
|
||||
modelReasoningEffort: "low",
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
it("falls back to the primary config when the adapter does not support the requested profile", () => {
|
||||
const modelProfile = resolveModelProfileApplication({
|
||||
adapterModelProfiles: [],
|
||||
agentRuntimeConfig: {
|
||||
modelProfiles: {
|
||||
cheap: {
|
||||
adapterConfig: {
|
||||
model: "agent-cheap",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
issueModelProfile: null,
|
||||
contextSnapshot: { modelProfile: "cheap" },
|
||||
});
|
||||
|
||||
const merged = mergeModelProfileAdapterConfig({
|
||||
baseConfig: {
|
||||
model: "primary",
|
||||
},
|
||||
modelProfile,
|
||||
issueAdapterConfig: null,
|
||||
});
|
||||
|
||||
expect(modelProfile).toMatchObject({
|
||||
requested: "cheap",
|
||||
applied: null,
|
||||
fallbackReason: "adapter_profile_not_supported",
|
||||
adapterConfig: null,
|
||||
});
|
||||
expect(merged).toEqual({ model: "primary" });
|
||||
});
|
||||
|
||||
it("normalizes a wake payload model profile into run context", () => {
|
||||
const contextSnapshot = normalizeModelProfileWakeContext({
|
||||
contextSnapshot: {},
|
||||
payload: { modelProfile: "cheap" },
|
||||
});
|
||||
|
||||
expect(contextSnapshot).toMatchObject({ modelProfile: "cheap" });
|
||||
});
|
||||
|
||||
it("treats model resolution failures as non-retryable configuration failures", () => {
|
||||
expect(isConfigurationIncompleteFailedRun({ errorCode: "model_not_found" })).toBe(true);
|
||||
expect(isConfigurationIncompleteFailedRun({ errorCode: "provider_quota" })).toBe(false);
|
||||
});
|
||||
});
|
||||
|
|
@ -43,7 +43,6 @@ vi.mock("../adapters/index.js", () => ({
|
|||
execute: adapterExecute,
|
||||
supportsLocalAgentJwt: false,
|
||||
}),
|
||||
listAdapterModelProfiles: async () => [],
|
||||
runningProcesses: new Map(),
|
||||
}));
|
||||
|
||||
|
|
|
|||
|
|
@ -26,7 +26,6 @@ vi.doMock("../adapters/index.js", () => ({
|
|||
execute: vi.fn(),
|
||||
testEnvironment: vi.fn(),
|
||||
})),
|
||||
listAdapterModelProfiles: vi.fn(() => []),
|
||||
runningProcesses: new Map(),
|
||||
}));
|
||||
|
||||
|
|
|
|||
|
|
@ -105,7 +105,6 @@ vi.mock("../adapters/index.js", () => ({
|
|||
execute: adapterExecute,
|
||||
supportsLocalAgentJwt: false,
|
||||
}),
|
||||
listAdapterModelProfiles: async () => [],
|
||||
runningProcesses: new Map(),
|
||||
}));
|
||||
|
||||
|
|
|
|||
|
|
@ -62,7 +62,6 @@ vi.mock("../adapters/index.js", () => ({
|
|||
execute: adapterExecute,
|
||||
supportsLocalAgentJwt: false,
|
||||
}),
|
||||
listAdapterModelProfiles: async () => [],
|
||||
runningProcesses: new Map(),
|
||||
}));
|
||||
|
||||
|
|
|
|||
|
|
@ -2117,7 +2117,6 @@ async function buildSessionConfigMetadata(
|
|||
maxConcurrentRuns: 1,
|
||||
},
|
||||
},
|
||||
modelProfile: null,
|
||||
issueOverrides: null,
|
||||
workspaceConfig: {
|
||||
requestedMode: "agent_default",
|
||||
|
|
@ -2330,24 +2329,13 @@ describe("effective run session config freshness", () => {
|
|||
expect(decision.reasons).toEqual([]);
|
||||
});
|
||||
|
||||
it("names safe categories for model profile, issue override, env, secret, and runtime skill drift", async () => {
|
||||
it("names safe categories for issue override, env, secret, and runtime skill drift", async () => {
|
||||
const base = await buildSessionConfigMetadata();
|
||||
const cases: Array<{
|
||||
name: string;
|
||||
category: string;
|
||||
metadata: SessionConfigMetadata;
|
||||
}> = [
|
||||
{
|
||||
name: "model profile",
|
||||
category: "modelProfile",
|
||||
metadata: await buildSessionConfigMetadata({
|
||||
modelProfile: {
|
||||
requested: "cheap",
|
||||
applied: true,
|
||||
configSource: "agent_runtime",
|
||||
},
|
||||
}),
|
||||
},
|
||||
{
|
||||
name: "issue overrides",
|
||||
category: "issueOverrides",
|
||||
|
|
|
|||
|
|
@ -1140,17 +1140,17 @@ describe("agent issue mutation checkout ownership", () => {
|
|||
provider: "test",
|
||||
title: "Artifact",
|
||||
}),
|
||||
"Cheap status-only recovery runs cannot update issue documents",
|
||||
"Status-only recovery runs cannot update issue documents",
|
||||
],
|
||||
[
|
||||
"work product update",
|
||||
(app: express.Express) => request(app).patch("/api/work-products/product-1").send({ title: "Blocked" }),
|
||||
"Cheap status-only recovery runs cannot update issue documents",
|
||||
"Status-only recovery runs cannot update issue documents",
|
||||
],
|
||||
[
|
||||
"work product delete",
|
||||
(app: express.Express) => request(app).delete("/api/work-products/product-1"),
|
||||
"Cheap status-only recovery runs cannot update issue documents",
|
||||
"Status-only recovery runs cannot update issue documents",
|
||||
],
|
||||
[
|
||||
"low-trust promotion",
|
||||
|
|
@ -1161,7 +1161,7 @@ describe("agent issue mutation checkout ownership", () => {
|
|||
title: "Promoted artifact",
|
||||
summary: "Sanitized output",
|
||||
}),
|
||||
"Cheap status-only recovery runs cannot update issue documents",
|
||||
"Status-only recovery runs cannot update issue documents",
|
||||
],
|
||||
[
|
||||
"attachment upload",
|
||||
|
|
@ -1169,12 +1169,12 @@ describe("agent issue mutation checkout ownership", () => {
|
|||
request(app)
|
||||
.post(`/api/companies/${companyId}/issues/${issueId}/attachments`)
|
||||
.attach("file", Buffer.from("report"), { filename: "report.txt", contentType: "text/plain" }),
|
||||
"Cheap status-only recovery runs cannot update issue documents",
|
||||
"Status-only recovery runs cannot update issue documents",
|
||||
],
|
||||
[
|
||||
"attachment delete",
|
||||
(app: express.Express) => request(app).delete("/api/attachments/attachment-1"),
|
||||
"Cheap status-only recovery runs cannot update issue documents",
|
||||
"Status-only recovery runs cannot update issue documents",
|
||||
],
|
||||
[
|
||||
"issue approval link",
|
||||
|
|
@ -1182,19 +1182,18 @@ describe("agent issue mutation checkout ownership", () => {
|
|||
request(app).post(`/api/issues/${issueId}/approvals`).send({
|
||||
approvalId: "88888888-8888-4888-8888-888888888888",
|
||||
}),
|
||||
"Cheap status-only recovery runs cannot create or modify approvals",
|
||||
"Status-only recovery runs cannot create or modify approvals",
|
||||
],
|
||||
[
|
||||
"issue approval unlink",
|
||||
(app: express.Express) =>
|
||||
request(app).delete(`/api/issues/${issueId}/approvals/88888888-8888-4888-8888-888888888888`),
|
||||
"Cheap status-only recovery runs cannot create or modify approvals",
|
||||
"Status-only recovery runs cannot create or modify approvals",
|
||||
],
|
||||
])("blocks cheap status-only recovery runs from %s", async (_name, sendRequest, expectedError) => {
|
||||
])("blocks status-only recovery runs from %s", async (_name, sendRequest, expectedError) => {
|
||||
const app = await createApp(
|
||||
ownerActor(),
|
||||
createRunContextDb({
|
||||
modelProfile: "cheap",
|
||||
recoveryIntent: "status_only",
|
||||
allowDeliverableWork: false,
|
||||
allowDocumentUpdates: false,
|
||||
|
|
@ -1217,51 +1216,6 @@ describe("agent issue mutation checkout ownership", () => {
|
|||
expect(mockIssueApprovalService.unlink).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it.each([
|
||||
[
|
||||
"issue create",
|
||||
(app: express.Express) =>
|
||||
request(app).post(`/api/companies/${companyId}/issues`).send({
|
||||
title: "Downstream source work",
|
||||
assigneeAdapterOverrides: { modelProfile: "cheap" },
|
||||
}),
|
||||
],
|
||||
[
|
||||
"child issue create",
|
||||
(app: express.Express) =>
|
||||
request(app).post(`/api/issues/${issueId}/children`).send({
|
||||
title: "Downstream child source work",
|
||||
assigneeAdapterOverrides: { modelProfile: "cheap" },
|
||||
}),
|
||||
],
|
||||
[
|
||||
"issue update",
|
||||
(app: express.Express) =>
|
||||
request(app).patch(`/api/issues/${issueId}`).send({
|
||||
assigneeAdapterOverrides: { modelProfile: "cheap" },
|
||||
}),
|
||||
],
|
||||
])("blocks cheap status-only recovery runs from propagating cheap profile through %s", async (_name, sendRequest) => {
|
||||
const app = await createApp(
|
||||
ownerActor(),
|
||||
createRunContextDb({
|
||||
modelProfile: "cheap",
|
||||
recoveryIntent: "status_only",
|
||||
allowDeliverableWork: false,
|
||||
allowDocumentUpdates: false,
|
||||
resumeRequiresNormalModel: true,
|
||||
}),
|
||||
);
|
||||
|
||||
const res = await sendRequest(app);
|
||||
|
||||
expect(res.status, JSON.stringify(res.body)).toBe(403);
|
||||
expect(res.body.error).toContain("cannot assign downstream issue work to the cheap model profile");
|
||||
expect(mockIssueService.create).not.toHaveBeenCalled();
|
||||
expect(mockIssueService.createChild).not.toHaveBeenCalled();
|
||||
expect(mockIssueService.update).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("defaults agent-created root follow-up issues to inherit the current run workspace", async () => {
|
||||
const app = await createApp(
|
||||
ownerActor(),
|
||||
|
|
@ -1494,20 +1448,15 @@ describe("agent issue mutation checkout ownership", () => {
|
|||
);
|
||||
});
|
||||
|
||||
it("allows board users to set explicit cheap issue assignee profile overrides", async () => {
|
||||
it("rejects retired issue assignee profile overrides", async () => {
|
||||
const app = await createApp(boardActor());
|
||||
|
||||
await request(app)
|
||||
.patch(`/api/issues/${issueId}`)
|
||||
.send({ assigneeAdapterOverrides: { modelProfile: "cheap" } })
|
||||
.expect(200);
|
||||
.expect(400);
|
||||
|
||||
expect(mockIssueService.update).toHaveBeenCalledWith(
|
||||
issueId,
|
||||
expect.objectContaining({
|
||||
assigneeAdapterOverrides: { modelProfile: "cheap" },
|
||||
}),
|
||||
);
|
||||
expect(mockIssueService.update).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("preserves committed issue updates, comments, documents, and work product writes when recovery revalidation fails", async () => {
|
||||
|
|
|
|||
|
|
@ -349,7 +349,7 @@ describe("issue document revision routes", () => {
|
|||
}));
|
||||
});
|
||||
|
||||
it("blocks cheap status-only recovery runs from restoring issue documents", async () => {
|
||||
it("blocks status-only recovery runs from restoring issue documents", async () => {
|
||||
mockIssueService.getById.mockResolvedValueOnce({
|
||||
id: issueId,
|
||||
companyId,
|
||||
|
|
@ -368,7 +368,6 @@ describe("issue document revision routes", () => {
|
|||
source: "agent_jwt",
|
||||
},
|
||||
createRunContextDb({
|
||||
modelProfile: "cheap",
|
||||
recoveryIntent: "status_only",
|
||||
allowDeliverableWork: false,
|
||||
allowDocumentUpdates: false,
|
||||
|
|
@ -379,7 +378,7 @@ describe("issue document revision routes", () => {
|
|||
.send({});
|
||||
|
||||
expect(res.status).toBe(403);
|
||||
expect(res.body.error).toContain("Cheap status-only recovery runs cannot update issue documents");
|
||||
expect(res.body.error).toContain("Status-only recovery runs cannot update issue documents");
|
||||
expect(mockDocumentsService.restoreIssueDocumentRevision).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -441,7 +441,6 @@ describeEmbeddedPostgres("issue monitor scheduler", () => {
|
|||
issueId,
|
||||
clearReason: "max_attempts_exhausted",
|
||||
maxAttempts: 1,
|
||||
modelProfile: "cheap",
|
||||
});
|
||||
|
||||
const activity = await db
|
||||
|
|
@ -484,7 +483,7 @@ describeEmbeddedPostgres("issue monitor scheduler", () => {
|
|||
expect(recoveryIssue).toMatchObject({
|
||||
parentId: issueId,
|
||||
priority: "high",
|
||||
assigneeAdapterOverrides: { modelProfile: "cheap" },
|
||||
assigneeAdapterOverrides: null,
|
||||
});
|
||||
expect(["todo", "in_progress"]).toContain(recoveryIssue?.status);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -40,7 +40,6 @@ vi.mock("../adapters/index.js", () => ({
|
|||
execute: adapterExecute,
|
||||
supportsLocalAgentJwt: false,
|
||||
}),
|
||||
listAdapterModelProfiles: async () => [],
|
||||
runningProcesses: new Map(),
|
||||
}));
|
||||
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ function manifest(): PaperclipPluginManifestV1 {
|
|||
capabilities: "Maintains a plugin-owned wiki.",
|
||||
adapterType: "process",
|
||||
adapterConfig: { command: "pnpm wiki:maintain" },
|
||||
runtimeConfig: { modelProfiles: { cheap: { enabled: true, adapterConfig: { model: "small" } } } },
|
||||
runtimeConfig: { heartbeat: { enabled: false } },
|
||||
permissions: { canCreateAgents: false },
|
||||
budgetMonthlyCents: 1234,
|
||||
},
|
||||
|
|
|
|||
|
|
@ -201,7 +201,7 @@ describeEmbeddedPostgres("productivity review service", () => {
|
|||
expect(reviews).toHaveLength(1);
|
||||
expect(reviews[0]?.parentId).toBe(seeded.issueId);
|
||||
expect(reviews[0]?.assigneeAgentId).toBe(seeded.managerId);
|
||||
expect(reviews[0]?.assigneeAdapterOverrides).toEqual({ modelProfile: "cheap" });
|
||||
expect(reviews[0]?.assigneeAdapterOverrides).toBeNull();
|
||||
expect(reviews[0]?.originId).toBe(seeded.issueId);
|
||||
expect(reviews[0]?.originFingerprint).toBe(`productivity-review:${seeded.issueId}`);
|
||||
expect(reviews[0]?.description).toContain("Primary trigger: `no_comment_streak`");
|
||||
|
|
|
|||
|
|
@ -754,15 +754,7 @@ describeEmbeddedPostgres("routine service live-execution coalescing", () => {
|
|||
},
|
||||
},
|
||||
runtimeConfig: {
|
||||
modelProfiles: {
|
||||
cheap: {
|
||||
adapterConfig: {
|
||||
env: {
|
||||
ROUTINE_ASSIGNEE_RUNTIME_SECRET: { type: "plain", value: sentinelSecret },
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
privateRuntimeSetting: { token: sentinelSecret },
|
||||
},
|
||||
})
|
||||
.where(eq(agents.id, agentId));
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ export {
|
|||
findServerAdapter,
|
||||
findActiveServerAdapter,
|
||||
detectAdapterModel,
|
||||
listAdapterModelProfiles,
|
||||
registerServerAdapter,
|
||||
unregisterServerAdapter,
|
||||
requireServerAdapter,
|
||||
|
|
@ -22,7 +21,6 @@ export type {
|
|||
AdapterRuntimeMcpAccess,
|
||||
AdapterRuntimeToolAccess,
|
||||
AdapterRuntimeToolDelivery,
|
||||
AdapterModelProfileDefinition,
|
||||
AdapterEnvironmentCheckLevel,
|
||||
AdapterEnvironmentCheck,
|
||||
AdapterEnvironmentTestStatus,
|
||||
|
|
|
|||
|
|
@ -1,8 +1,4 @@
|
|||
import type {
|
||||
AdapterModelProfileDefinition,
|
||||
AdapterRuntimeCommandSpec,
|
||||
ServerAdapterModule,
|
||||
} from "./types.js";
|
||||
import type { AdapterRuntimeCommandSpec, ServerAdapterModule } from "./types.js";
|
||||
import { parseAdapterModelsEnv } from "../services/adapter-models-env.js";
|
||||
import { stampClaudeAgentIdHeader } from "./claude-agent-id-header.js";
|
||||
import {
|
||||
|
|
@ -29,7 +25,6 @@ import {
|
|||
import {
|
||||
agentConfigurationDoc as claudeAgentConfigurationDoc,
|
||||
models as claudeModels,
|
||||
modelProfiles as claudeModelProfiles,
|
||||
} from "@paperclipai/adapter-claude-local";
|
||||
import {
|
||||
execute as codexExecute,
|
||||
|
|
@ -45,7 +40,6 @@ import {
|
|||
import {
|
||||
agentConfigurationDoc as codexAgentConfigurationDoc,
|
||||
models as codexModels,
|
||||
modelProfiles as codexModelProfiles,
|
||||
} from "@paperclipai/adapter-codex-local";
|
||||
import {
|
||||
execute as cursorExecute,
|
||||
|
|
@ -57,7 +51,6 @@ import {
|
|||
import {
|
||||
agentConfigurationDoc as cursorAgentConfigurationDoc,
|
||||
models as cursorModels,
|
||||
modelProfiles as cursorModelProfiles,
|
||||
} from "@paperclipai/adapter-cursor-local";
|
||||
import {
|
||||
execute as cursorCloudExecute,
|
||||
|
|
@ -77,7 +70,6 @@ import {
|
|||
import {
|
||||
agentConfigurationDoc as geminiAgentConfigurationDoc,
|
||||
models as geminiModels,
|
||||
modelProfiles as geminiModelProfiles,
|
||||
} from "@paperclipai/adapter-gemini-local";
|
||||
import {
|
||||
execute as grokExecute,
|
||||
|
|
@ -118,7 +110,6 @@ import {
|
|||
import {
|
||||
agentConfigurationDoc as openCodeAgentConfigurationDoc,
|
||||
models as openCodeModels,
|
||||
modelProfiles as openCodeModelProfiles,
|
||||
} from "@paperclipai/adapter-opencode-local";
|
||||
import {
|
||||
execute as openclawGatewayExecute,
|
||||
|
|
@ -138,10 +129,7 @@ import {
|
|||
sessionCodec as piSessionCodec,
|
||||
listPiModels,
|
||||
} from "@paperclipai/adapter-pi-local/server";
|
||||
import {
|
||||
agentConfigurationDoc as piAgentConfigurationDoc,
|
||||
modelProfiles as piModelProfiles,
|
||||
} from "@paperclipai/adapter-pi-local";
|
||||
import { agentConfigurationDoc as piAgentConfigurationDoc } from "@paperclipai/adapter-pi-local";
|
||||
import { BUILTIN_ADAPTER_TYPES } from "./builtin-adapter-types.js";
|
||||
import { buildExternalAdapters } from "./plugin-loader.js";
|
||||
import { getDisabledAdapterTypes } from "../services/adapter-plugin-store.js";
|
||||
|
|
@ -274,7 +262,6 @@ const claudeLocalAdapter: ServerAdapterModule = {
|
|||
sessionCodec: claudeSessionCodec,
|
||||
sessionManagement: getAdapterSessionManagement("claude_local") ?? undefined,
|
||||
models: claudeModels,
|
||||
modelProfiles: claudeModelProfiles,
|
||||
listModels: listClaudeModels,
|
||||
refreshModels: refreshClaudeModels,
|
||||
supportsLocalAgentJwt: true,
|
||||
|
|
@ -350,7 +337,6 @@ const codexLocalAdapter: ServerAdapterModule = {
|
|||
sessionCodec: codexSessionCodec,
|
||||
sessionManagement: getAdapterSessionManagement("codex_local") ?? undefined,
|
||||
models: codexModels,
|
||||
modelProfiles: codexModelProfiles,
|
||||
listModels: listCodexModels,
|
||||
refreshModels: refreshCodexModels,
|
||||
supportsLocalAgentJwt: true,
|
||||
|
|
@ -430,7 +416,6 @@ const paperclipRunnerAdapter: ServerAdapterModule = {
|
|||
syncSkills: syncCodexSkills,
|
||||
sessionCodec: codexSessionCodec,
|
||||
models: codexModels,
|
||||
modelProfiles: codexModelProfiles,
|
||||
listModels: listCodexModels,
|
||||
refreshModels: refreshCodexModels,
|
||||
supportsLocalAgentJwt: false,
|
||||
|
|
@ -484,7 +469,6 @@ const cursorLocalAdapter: ServerAdapterModule = {
|
|||
sessionCodec: cursorSessionCodec,
|
||||
sessionManagement: getAdapterSessionManagement("cursor") ?? undefined,
|
||||
models: cursorModels,
|
||||
modelProfiles: cursorModelProfiles,
|
||||
listModels: listCursorModels,
|
||||
supportsLocalAgentJwt: true,
|
||||
supportsInstructionsBundle: true,
|
||||
|
|
@ -528,7 +512,6 @@ const geminiLocalAdapter: ServerAdapterModule = {
|
|||
sessionCodec: geminiSessionCodec,
|
||||
sessionManagement: getAdapterSessionManagement("gemini_local") ?? undefined,
|
||||
models: geminiModels,
|
||||
modelProfiles: geminiModelProfiles,
|
||||
supportsLocalAgentJwt: true,
|
||||
supportsInstructionsBundle: true,
|
||||
instructionsPathKey: "instructionsFilePath",
|
||||
|
|
@ -620,7 +603,6 @@ const openCodeLocalAdapter: ServerAdapterModule = {
|
|||
syncSkills: syncOpenCodeSkills,
|
||||
sessionCodec: openCodeSessionCodec,
|
||||
models: openCodeModels,
|
||||
modelProfiles: openCodeModelProfiles,
|
||||
sessionManagement: getAdapterSessionManagement("opencode_local") ?? undefined,
|
||||
listModels: listOpenCodeModels,
|
||||
supportsLocalAgentJwt: true,
|
||||
|
|
@ -641,7 +623,6 @@ const piLocalAdapter: ServerAdapterModule = {
|
|||
sessionCodec: piSessionCodec,
|
||||
sessionManagement: getAdapterSessionManagement("pi_local") ?? undefined,
|
||||
models: [],
|
||||
modelProfiles: piModelProfiles,
|
||||
listModels: listPiModels,
|
||||
supportsLocalAgentJwt: true,
|
||||
supportsInstructionsBundle: true,
|
||||
|
|
@ -869,16 +850,6 @@ export async function refreshAdapterModels(type: string): Promise<{ id: string;
|
|||
return adapter.models ?? [];
|
||||
}
|
||||
|
||||
export async function listAdapterModelProfiles(type: string): Promise<AdapterModelProfileDefinition[]> {
|
||||
const adapter = findActiveServerAdapter(type);
|
||||
if (!adapter) return [];
|
||||
if (adapter.listModelProfiles) {
|
||||
const discovered = await adapter.listModelProfiles();
|
||||
if (discovered.length > 0) return discovered;
|
||||
}
|
||||
return adapter.modelProfiles ?? [];
|
||||
}
|
||||
|
||||
export function listServerAdapters(): ServerAdapterModule[] {
|
||||
return Array.from(adaptersByType.values());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,8 +24,6 @@ export type {
|
|||
AdapterSkillContext,
|
||||
AdapterSessionCodec,
|
||||
AdapterModel,
|
||||
AdapterModelProfileKey,
|
||||
AdapterModelProfileDefinition,
|
||||
NativeContextManagement,
|
||||
ResolvedSessionCompactionPolicy,
|
||||
SessionCompactionPolicy,
|
||||
|
|
|
|||
|
|
@ -24,12 +24,9 @@ Your job is to turn the current state of a Paperclip scope — a project, the wo
|
|||
- Keep every read company-scoped. Do not cross company boundaries.
|
||||
- Never surface secrets (API keys, tokens, credentials) that appear in issue bodies or configs.
|
||||
|
||||
## Model lane
|
||||
|
||||
You run on the low-cost model profile lane (`cheap`) by default and spend no tokens in the background. Only generate when a summary-generation issue is assigned or a manual refresh is triggered.
|
||||
Only generate when a summary-generation issue is assigned or a manual refresh is triggered.
|
||||
|
||||
- Keep summaries short — a header summary that scrolls or reads like a task list has failed its job.
|
||||
- An operator may override the cheap default with a specific model in this agent's `cheap` model profile configuration. Respect whatever model the run actually provides.
|
||||
|
||||
## Execution contract
|
||||
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ This routine is **paused by default** and spends no tokens until an operator ena
|
|||
|
||||
- Read-and-report only. This routine must never change issues, workspaces, code, or agent configuration — its only write is the summary revision.
|
||||
- Keep every read company-scoped. Do not cross company boundaries.
|
||||
- Run on the low-cost model profile lane (`cheap`). Keep each summary short.
|
||||
- Keep each summary short.
|
||||
- Never fabricate status and never surface secrets from issue bodies or configs.
|
||||
|
||||
## Output
|
||||
|
|
|
|||
|
|
@ -115,7 +115,6 @@ interface AdapterCapabilities {
|
|||
supportsSkills: boolean;
|
||||
supportsLocalAgentJwt: boolean;
|
||||
requiresMaterializedRuntimeSkills: boolean;
|
||||
supportsModelProfiles: boolean;
|
||||
supportsAcp: boolean;
|
||||
/**
|
||||
* The projected login capability. It is present only when the adapter
|
||||
|
|
@ -182,7 +181,6 @@ export function buildAdapterCapabilities(adapter: ServerAdapterModule): AdapterC
|
|||
supportsSkills: Boolean(adapter.listSkills || adapter.syncSkills),
|
||||
supportsLocalAgentJwt: adapter.supportsLocalAgentJwt ?? false,
|
||||
requiresMaterializedRuntimeSkills: adapter.requiresMaterializedRuntimeSkills ?? false,
|
||||
supportsModelProfiles: Boolean(adapter.modelProfiles?.length || adapter.listModelProfiles),
|
||||
supportsAcp: Boolean(adapter.acp),
|
||||
...(login
|
||||
? {
|
||||
|
|
|
|||
|
|
@ -80,7 +80,6 @@ import type { AdapterExecutionTarget } from "@paperclipai/adapter-utils/executio
|
|||
import type {
|
||||
AdapterEnvironmentCheck,
|
||||
AdapterEnvironmentTestResult,
|
||||
AdapterModelProfileDefinition,
|
||||
} from "@paperclipai/adapter-utils";
|
||||
import { evaluateCodexCredentialReadiness } from "@paperclipai/adapter-codex-local/server";
|
||||
import type { AdapterAuthSignal, AdapterAuthSignalResponse } from "@paperclipai/shared";
|
||||
|
|
@ -100,7 +99,6 @@ import {
|
|||
findServerAdapter,
|
||||
listServerAdapters,
|
||||
listAdapterModels,
|
||||
listAdapterModelProfiles,
|
||||
refreshAdapterModels,
|
||||
requireServerAdapter,
|
||||
} from "../adapters/index.js";
|
||||
|
|
@ -1863,24 +1861,7 @@ export function agentRoutes(
|
|||
};
|
||||
}
|
||||
|
||||
async function listNewAgentAdapterModelProfiles(
|
||||
adapterType: string,
|
||||
): Promise<AdapterModelProfileDefinition[]> {
|
||||
try {
|
||||
return await listAdapterModelProfiles(adapterType);
|
||||
} catch (error) {
|
||||
logger.warn(
|
||||
{ err: error, adapterType },
|
||||
"Failed to discover adapter model profiles while normalizing a new agent; continuing without profile defaults",
|
||||
);
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
async function normalizeNewAgentRuntimeConfig(
|
||||
adapterType: string,
|
||||
runtimeConfig: unknown,
|
||||
): Promise<Record<string, unknown>> {
|
||||
function normalizeNewAgentRuntimeConfig(runtimeConfig: unknown): Record<string, unknown> {
|
||||
const parsedRuntimeConfig = asRecord(runtimeConfig);
|
||||
const normalizedRuntimeConfig = parsedRuntimeConfig ? { ...parsedRuntimeConfig } : {};
|
||||
const parsedHeartbeat = asRecord(normalizedRuntimeConfig.heartbeat);
|
||||
|
|
@ -1895,57 +1876,9 @@ export function agentRoutes(
|
|||
|
||||
normalizedRuntimeConfig.heartbeat = heartbeat;
|
||||
|
||||
const parsedModelProfiles = asRecord(normalizedRuntimeConfig.modelProfiles);
|
||||
const modelProfiles = parsedModelProfiles ? { ...parsedModelProfiles } : {};
|
||||
if (!Object.prototype.hasOwnProperty.call(modelProfiles, "cheap")) {
|
||||
const adapterModelProfiles = await listNewAgentAdapterModelProfiles(adapterType);
|
||||
if (adapterModelProfiles.some((profile) => profile.key === "cheap")) {
|
||||
modelProfiles.cheap = { enabled: false };
|
||||
}
|
||||
}
|
||||
if (Object.keys(modelProfiles).length > 0) {
|
||||
normalizedRuntimeConfig.modelProfiles = modelProfiles;
|
||||
}
|
||||
|
||||
return normalizedRuntimeConfig;
|
||||
}
|
||||
|
||||
function listRuntimeModelProfileAdapterConfigs(runtimeConfig: unknown): Array<{
|
||||
profileKey: string;
|
||||
profile: Record<string, unknown>;
|
||||
adapterConfig: Record<string, unknown>;
|
||||
path: string;
|
||||
}> {
|
||||
const runtimeRecord = asRecord(runtimeConfig);
|
||||
const modelProfiles = asRecord(runtimeRecord?.modelProfiles);
|
||||
if (!modelProfiles) return [];
|
||||
|
||||
const entries: Array<{
|
||||
profileKey: string;
|
||||
profile: Record<string, unknown>;
|
||||
adapterConfig: Record<string, unknown>;
|
||||
path: string;
|
||||
}> = [];
|
||||
for (const [profileKey, rawProfile] of Object.entries(modelProfiles)) {
|
||||
const profile = asRecord(rawProfile);
|
||||
const adapterConfig = asRecord(profile?.adapterConfig);
|
||||
if (!profile || !adapterConfig) continue;
|
||||
entries.push({
|
||||
profileKey,
|
||||
profile,
|
||||
adapterConfig,
|
||||
path: `runtimeConfig.modelProfiles.${profileKey}.adapterConfig`,
|
||||
});
|
||||
}
|
||||
return entries;
|
||||
}
|
||||
|
||||
function assertNoAgentRuntimeConfigAdapterConfigMutation(req: Request, runtimeConfig: unknown) {
|
||||
for (const entry of listRuntimeModelProfileAdapterConfigs(runtimeConfig)) {
|
||||
assertNoAgentAdapterConfigMutation(req, entry.adapterConfig, entry.path);
|
||||
}
|
||||
}
|
||||
|
||||
async function normalizeMediatedAdapterConfigForPersistence(input: {
|
||||
companyId: string;
|
||||
adapterType: string | null | undefined;
|
||||
|
|
@ -1969,42 +1902,6 @@ export function agentRoutes(
|
|||
return normalizedAdapterConfig;
|
||||
}
|
||||
|
||||
async function normalizeRuntimeConfigAdapterConfigsForPersistence(
|
||||
companyId: string,
|
||||
adapterType: string,
|
||||
runtimeConfig: Record<string, unknown>,
|
||||
baseAdapterConfig: Record<string, unknown>,
|
||||
): Promise<Record<string, unknown>> {
|
||||
const entries = listRuntimeModelProfileAdapterConfigs(runtimeConfig);
|
||||
if (entries.length === 0) return runtimeConfig;
|
||||
const adapterModelProfiles = await listNewAgentAdapterModelProfiles(adapterType);
|
||||
|
||||
const normalizedRuntimeConfig = { ...runtimeConfig };
|
||||
const modelProfiles = asRecord(runtimeConfig.modelProfiles) ?? {};
|
||||
const normalizedModelProfiles = { ...modelProfiles };
|
||||
normalizedRuntimeConfig.modelProfiles = normalizedModelProfiles;
|
||||
|
||||
for (const entry of entries) {
|
||||
const adapterProfile = adapterModelProfiles.find((profile) => profile.key === entry.profileKey);
|
||||
const adapterDefaultConfig = asRecord(adapterProfile?.adapterConfig) ?? {};
|
||||
const normalizedAdapterConfig = await normalizeMediatedAdapterConfigForPersistence({
|
||||
companyId,
|
||||
adapterType,
|
||||
adapterConfig: entry.adapterConfig,
|
||||
constraintAdapterConfig: {
|
||||
...baseAdapterConfig,
|
||||
...adapterDefaultConfig,
|
||||
},
|
||||
});
|
||||
normalizedModelProfiles[entry.profileKey] = {
|
||||
...entry.profile,
|
||||
adapterConfig: normalizedAdapterConfig,
|
||||
};
|
||||
}
|
||||
|
||||
return normalizedRuntimeConfig;
|
||||
}
|
||||
|
||||
function generateEd25519PrivateKeyPem(): string {
|
||||
const { privateKey } = generateKeyPairSync("ed25519");
|
||||
return privateKey.export({ type: "pkcs8", format: "pem" }).toString();
|
||||
|
|
@ -2609,14 +2506,6 @@ export function agentRoutes(
|
|||
res.json(models);
|
||||
});
|
||||
|
||||
router.get("/companies/:companyId/adapters/:type/model-profiles", async (req, res) => {
|
||||
const companyId = req.params.companyId as string;
|
||||
assertCompanyAccess(req, companyId);
|
||||
const type = assertKnownAdapterType(req.params.type as string);
|
||||
const profiles = await listAdapterModelProfiles(type);
|
||||
res.json(profiles);
|
||||
});
|
||||
|
||||
router.get("/companies/:companyId/adapters/:type/detect-model", async (req, res) => {
|
||||
const companyId = req.params.companyId as string;
|
||||
assertCompanyAccess(req, companyId);
|
||||
|
|
@ -3641,7 +3530,6 @@ export function agentRoutes(
|
|||
rawHireAdapterConfig,
|
||||
);
|
||||
assertNoAgentAdapterConfigMutation(req, rawHireAdapterConfig);
|
||||
assertNoAgentRuntimeConfigAdapterConfigMutation(req, hireInput.runtimeConfig);
|
||||
const hiredAgentId = randomUUID();
|
||||
const requestedAdapterConfig = applyCodexLocalKeyIsolation(
|
||||
companyId,
|
||||
|
|
@ -3667,12 +3555,7 @@ export function agentRoutes(
|
|||
adapterType: hireInput.adapterType,
|
||||
adapterConfig: desiredSkillAssignment.adapterConfig,
|
||||
});
|
||||
const normalizedRuntimeConfig = await normalizeRuntimeConfigAdapterConfigsForPersistence(
|
||||
companyId,
|
||||
hireInput.adapterType,
|
||||
await normalizeNewAgentRuntimeConfig(hireInput.adapterType, hireInput.runtimeConfig),
|
||||
normalizedAdapterConfig,
|
||||
);
|
||||
const normalizedRuntimeConfig = normalizeNewAgentRuntimeConfig(hireInput.runtimeConfig);
|
||||
const normalizedHireInput = {
|
||||
...hireInput,
|
||||
adapterConfig: normalizedAdapterConfig,
|
||||
|
|
@ -3865,7 +3748,6 @@ export function agentRoutes(
|
|||
rawCreateAdapterConfig,
|
||||
);
|
||||
assertNoAgentAdapterConfigMutation(req, rawCreateAdapterConfig);
|
||||
assertNoAgentRuntimeConfigAdapterConfigMutation(req, createInput.runtimeConfig);
|
||||
const agentId = randomUUID();
|
||||
const requestedAdapterConfig = applyCodexLocalKeyIsolation(
|
||||
companyId,
|
||||
|
|
@ -3891,12 +3773,7 @@ export function agentRoutes(
|
|||
adapterType: createInput.adapterType,
|
||||
adapterConfig: desiredSkillAssignment.adapterConfig,
|
||||
});
|
||||
const normalizedRuntimeConfig = await normalizeRuntimeConfigAdapterConfigsForPersistence(
|
||||
companyId,
|
||||
createInput.adapterType,
|
||||
await normalizeNewAgentRuntimeConfig(createInput.adapterType, createInput.runtimeConfig),
|
||||
normalizedAdapterConfig,
|
||||
);
|
||||
const normalizedRuntimeConfig = normalizeNewAgentRuntimeConfig(createInput.runtimeConfig);
|
||||
await assertAgentEnvironmentSelection(companyId, createInput.adapterType, createInput.defaultEnvironmentId);
|
||||
await assertAgentDefaultEnvironmentSelection(companyId, createInput.defaultEnvironmentId, {
|
||||
allowedDrivers: allowedEnvironmentDriversForAgent(createInput.adapterType),
|
||||
|
|
@ -4308,7 +4185,6 @@ export function agentRoutes(
|
|||
res.status(422).json({ error: "runtimeConfig must be an object" });
|
||||
return;
|
||||
}
|
||||
assertNoAgentRuntimeConfigAdapterConfigMutation(req, runtimeConfig);
|
||||
assertProviderTraceSettingTransition(
|
||||
req,
|
||||
runtimeConfig,
|
||||
|
|
@ -4384,15 +4260,7 @@ export function agentRoutes(
|
|||
});
|
||||
patchData.adapterConfig = syncInstructionsBundleConfigFromFilePath(existing, normalizedEffectiveAdapterConfig);
|
||||
}
|
||||
if (requestedRuntimeConfig) {
|
||||
const baseAdapterConfig = asRecord(patchData.adapterConfig) ?? asRecord(existing.adapterConfig) ?? {};
|
||||
patchData.runtimeConfig = await normalizeRuntimeConfigAdapterConfigsForPersistence(
|
||||
existing.companyId,
|
||||
requestedAdapterType,
|
||||
requestedRuntimeConfig,
|
||||
baseAdapterConfig,
|
||||
);
|
||||
}
|
||||
if (requestedRuntimeConfig) patchData.runtimeConfig = requestedRuntimeConfig;
|
||||
if (touchesAdapterConfiguration || Object.prototype.hasOwnProperty.call(patchData, "defaultEnvironmentId")) {
|
||||
await assertAgentDefaultEnvironmentSelection(
|
||||
existing.companyId,
|
||||
|
|
|
|||
|
|
@ -31,11 +31,10 @@ function redactApprovalPayload<T extends { payload: Record<string, unknown> }>(a
|
|||
};
|
||||
}
|
||||
|
||||
function isStatusOnlyCheapRecoveryContext(contextSnapshot: unknown) {
|
||||
function isStatusOnlyRecoveryContext(contextSnapshot: unknown) {
|
||||
if (!contextSnapshot || typeof contextSnapshot !== "object" || Array.isArray(contextSnapshot)) return false;
|
||||
const context = contextSnapshot as Record<string, unknown>;
|
||||
return context.modelProfile === "cheap" &&
|
||||
context.recoveryIntent === "status_only" &&
|
||||
return context.recoveryIntent === "status_only" &&
|
||||
context.allowDeliverableWork === false &&
|
||||
context.allowDocumentUpdates === false &&
|
||||
context.resumeRequiresNormalModel === true;
|
||||
|
|
@ -189,14 +188,13 @@ export function approvalRoutes(
|
|||
.where(eq(heartbeatRuns.id, runId))
|
||||
.then((rows) => rows[0] ?? null);
|
||||
if (!run || run.companyId !== companyId || run.agentId !== req.actor.agentId) return true;
|
||||
if (!isStatusOnlyCheapRecoveryContext(run.contextSnapshot)) return true;
|
||||
if (!isStatusOnlyRecoveryContext(run.contextSnapshot)) return true;
|
||||
|
||||
res.status(403).json({
|
||||
error: "Cheap status-only recovery runs cannot create or modify approvals",
|
||||
error: "Status-only recovery runs cannot create or modify approvals",
|
||||
details: {
|
||||
companyId,
|
||||
runId: run.id,
|
||||
modelProfile: "cheap",
|
||||
recoveryIntent: "status_only",
|
||||
resumeRequiresNormalModel: true,
|
||||
},
|
||||
|
|
|
|||
|
|
@ -4932,24 +4932,15 @@ export function issueRoutes(
|
|||
return { scope, discovery, sourceIssue, watchdogIssue };
|
||||
}
|
||||
|
||||
function isStatusOnlyCheapRecoveryContext(contextSnapshot: unknown) {
|
||||
function isStatusOnlyRecoveryContext(contextSnapshot: unknown) {
|
||||
if (!contextSnapshot || typeof contextSnapshot !== "object" || Array.isArray(contextSnapshot)) return false;
|
||||
const context = contextSnapshot as Record<string, unknown>;
|
||||
return context.modelProfile === "cheap" &&
|
||||
context.recoveryIntent === "status_only" &&
|
||||
return context.recoveryIntent === "status_only" &&
|
||||
context.allowDeliverableWork === false &&
|
||||
context.allowDocumentUpdates === false &&
|
||||
context.resumeRequiresNormalModel === true;
|
||||
}
|
||||
|
||||
function requestsCheapIssueAssigneeModelProfile(input: { assigneeAdapterOverrides?: unknown }) {
|
||||
const overrides = input.assigneeAdapterOverrides;
|
||||
return !!overrides &&
|
||||
typeof overrides === "object" &&
|
||||
!Array.isArray(overrides) &&
|
||||
(overrides as Record<string, unknown>).modelProfile === "cheap";
|
||||
}
|
||||
|
||||
async function loadActorRunContext(req: Request, companyId: string) {
|
||||
if (req.actor.type !== "agent") return null;
|
||||
const runId = req.actor.runId?.trim();
|
||||
|
|
@ -5015,29 +5006,6 @@ export function issueRoutes(
|
|||
};
|
||||
}
|
||||
|
||||
async function assertCheapRecoveryIssueAssigneeProfileAllowed(
|
||||
req: Request,
|
||||
res: Response,
|
||||
issue: { id?: string; companyId: string },
|
||||
input: { assigneeAdapterOverrides?: unknown },
|
||||
) {
|
||||
if (!requestsCheapIssueAssigneeModelProfile(input)) return true;
|
||||
const run = await loadActorRunContext(req, issue.companyId);
|
||||
if (!run || !isStatusOnlyCheapRecoveryContext(run.contextSnapshot)) return true;
|
||||
|
||||
res.status(403).json({
|
||||
error: "Cheap status-only recovery runs cannot assign downstream issue work to the cheap model profile",
|
||||
details: {
|
||||
issueId: issue.id ?? null,
|
||||
runId: run.id,
|
||||
modelProfile: "cheap",
|
||||
recoveryIntent: "status_only",
|
||||
resumeRequiresNormalModel: true,
|
||||
},
|
||||
});
|
||||
return false;
|
||||
}
|
||||
|
||||
async function assertDeliverableMutationAllowedByRunContext(
|
||||
req: Request,
|
||||
res: Response,
|
||||
|
|
@ -5045,14 +5013,13 @@ export function issueRoutes(
|
|||
) {
|
||||
const run = await loadActorRunContext(req, issue.companyId);
|
||||
if (!run) return true;
|
||||
if (!isStatusOnlyCheapRecoveryContext(run.contextSnapshot)) return true;
|
||||
if (!isStatusOnlyRecoveryContext(run.contextSnapshot)) return true;
|
||||
|
||||
res.status(403).json({
|
||||
error: "Cheap status-only recovery runs cannot update issue documents, plans, or deliverable artifacts",
|
||||
error: "Status-only recovery runs cannot update issue documents, plans, or deliverable artifacts",
|
||||
details: {
|
||||
issueId: issue.id,
|
||||
runId: run.id,
|
||||
modelProfile: "cheap",
|
||||
recoveryIntent: "status_only",
|
||||
resumeRequiresNormalModel: true,
|
||||
},
|
||||
|
|
@ -5067,14 +5034,13 @@ export function issueRoutes(
|
|||
) {
|
||||
const run = await loadActorRunContext(req, issue.companyId);
|
||||
if (!run) return true;
|
||||
if (!isStatusOnlyCheapRecoveryContext(run.contextSnapshot)) return true;
|
||||
if (!isStatusOnlyRecoveryContext(run.contextSnapshot)) return true;
|
||||
|
||||
res.status(403).json({
|
||||
error: "Cheap status-only recovery runs cannot create or modify approvals",
|
||||
error: "Status-only recovery runs cannot create or modify approvals",
|
||||
details: {
|
||||
issueId: issue.id,
|
||||
runId: run.id,
|
||||
modelProfile: "cheap",
|
||||
recoveryIntent: "status_only",
|
||||
resumeRequiresNormalModel: true,
|
||||
},
|
||||
|
|
@ -9127,7 +9093,6 @@ export function issueRoutes(
|
|||
}
|
||||
: {}),
|
||||
};
|
||||
if (!(await assertCheapRecoveryIssueAssigneeProfileAllowed(req, res, { companyId }, createBody))) return;
|
||||
const createAssignmentScope = {
|
||||
projectId: await resolveAssignmentProjectId({
|
||||
companyId,
|
||||
|
|
@ -9363,7 +9328,6 @@ export function issueRoutes(
|
|||
...sanitizedBody,
|
||||
...(normalizedAssigneeAgentId !== undefined ? { assigneeAgentId: normalizedAssigneeAgentId } : {}),
|
||||
};
|
||||
if (!(await assertCheapRecoveryIssueAssigneeProfileAllowed(req, res, parent, createBody))) return;
|
||||
const childAssignmentScope = {
|
||||
projectId: createBody.projectId ?? parent.projectId ?? null,
|
||||
parentIssueId: parent.id,
|
||||
|
|
@ -9542,7 +9506,6 @@ export function issueRoutes(
|
|||
};
|
||||
requestedChildren.push(childBody);
|
||||
assertNoAgentHostWorkspaceCommandMutation(req, collectIssueWorkspaceCommandPaths(childBody));
|
||||
if (!(await assertCheapRecoveryIssueAssigneeProfileAllowed(req, res, sourceIssue, childBody))) return;
|
||||
if (childBody.assigneeAgentId || childBody.assigneeUserId) {
|
||||
await assertCanAssignTasks(req, sourceIssue.companyId, {
|
||||
projectId: childBody.projectId ?? sourceIssue.projectId ?? null,
|
||||
|
|
@ -9913,7 +9876,6 @@ export function issueRoutes(
|
|||
const issueMutationAuthorizationReason = req.actor.type === "agent"
|
||||
? issueWriteAuthorizationReason(req, await decideIssueAccess(req, existing, "issue:mutate"))
|
||||
: issueWriteAuthorizationReason(req, true);
|
||||
if (!(await assertCheapRecoveryIssueAssigneeProfileAllowed(req, res, existing, req.body))) return;
|
||||
|
||||
const actor = getActorInfo(req);
|
||||
const isClosed = isClosedIssueStatus(existing.status);
|
||||
|
|
|
|||
|
|
@ -6815,13 +6815,6 @@ registerCurrentRoute({
|
|||
summary: "Get adapter registration details",
|
||||
});
|
||||
|
||||
registerCurrentRoute({
|
||||
method: "get",
|
||||
path: "/api/companies/{companyId}/adapters/{type}/model-profiles",
|
||||
tags: ["adapters"],
|
||||
summary: "List adapter model profiles for a company",
|
||||
});
|
||||
|
||||
registerCurrentRoute({
|
||||
method: "post",
|
||||
path: "/api/health/dev-server/restart",
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ import {
|
|||
} from "@paperclipai/db";
|
||||
import {
|
||||
AGENT_DEFAULT_MAX_CONCURRENT_RUNS,
|
||||
agentRuntimeConfigSchema,
|
||||
getAgentWorkEligibility,
|
||||
isUuidLike,
|
||||
normalizeAgentApiKeyScope,
|
||||
|
|
@ -288,6 +289,12 @@ function configPatchFromSnapshot(snapshot: unknown): Partial<typeof agents.$infe
|
|||
if (typeof snapshot.budgetMonthlyCents !== "number" || !Number.isFinite(snapshot.budgetMonthlyCents)) {
|
||||
throw unprocessable("Invalid revision snapshot: budgetMonthlyCents");
|
||||
}
|
||||
const runtimeConfig = agentRuntimeConfigSchema.safeParse(
|
||||
isPlainRecord(snapshot.runtimeConfig) ? snapshot.runtimeConfig : {},
|
||||
);
|
||||
if (!runtimeConfig.success) {
|
||||
throw unprocessable("Invalid revision snapshot: runtimeConfig");
|
||||
}
|
||||
|
||||
return {
|
||||
name: snapshot.name,
|
||||
|
|
@ -301,7 +308,7 @@ function configPatchFromSnapshot(snapshot: unknown): Partial<typeof agents.$infe
|
|||
: null,
|
||||
adapterType: snapshot.adapterType,
|
||||
adapterConfig: isPlainRecord(snapshot.adapterConfig) ? snapshot.adapterConfig : {},
|
||||
runtimeConfig: isPlainRecord(snapshot.runtimeConfig) ? snapshot.runtimeConfig : {},
|
||||
runtimeConfig: runtimeConfig.data,
|
||||
defaultEnvironmentId:
|
||||
typeof snapshot.defaultEnvironmentId === "string" || snapshot.defaultEnvironmentId === null
|
||||
? snapshot.defaultEnvironmentId
|
||||
|
|
|
|||
|
|
@ -1306,6 +1306,7 @@ function parseFiniteNumberLike(value: unknown): number | null {
|
|||
|
||||
function sanitizeImportedAgentRuntimeConfig(runtimeConfig: unknown) {
|
||||
const next = clonePortableRecord(runtimeConfig) ?? {};
|
||||
delete next.modelProfiles;
|
||||
const heartbeat = isPlainRecord(next.heartbeat) ? { ...next.heartbeat } : {};
|
||||
heartbeat.enabled = false;
|
||||
if (parseFiniteNumberLike(heartbeat.maxConcurrentRuns) == null) {
|
||||
|
|
@ -1325,6 +1326,13 @@ function sanitizeImportedAgentRuntimeConfig(runtimeConfig: unknown) {
|
|||
return next;
|
||||
}
|
||||
|
||||
function sanitizeImportedIssueAssigneeAdapterOverrides(value: unknown) {
|
||||
const next = clonePortableRecord(value);
|
||||
if (!next) return null;
|
||||
delete next.modelProfile;
|
||||
return Object.keys(next).length > 0 ? next : null;
|
||||
}
|
||||
|
||||
function normalizePortableProjectWorkspaceExtension(
|
||||
workspaceKey: string,
|
||||
value: unknown,
|
||||
|
|
@ -6249,7 +6257,9 @@ export function companyPortabilityService(db: Db, storage?: StorageService) {
|
|||
? manifestIssue.priority as typeof ISSUE_PRIORITIES[number]
|
||||
: "medium",
|
||||
billingCode: manifestIssue.billingCode ?? null,
|
||||
assigneeAdapterOverrides: manifestIssue.assigneeAdapterOverrides ?? null,
|
||||
assigneeAdapterOverrides: sanitizeImportedIssueAssigneeAdapterOverrides(
|
||||
manifestIssue.assigneeAdapterOverrides,
|
||||
),
|
||||
executionWorkspaceSettings: manifestIssue.executionWorkspaceSettings ?? null,
|
||||
labelIds: resolvedLabelIds,
|
||||
monitorNotes,
|
||||
|
|
|
|||
|
|
@ -27,7 +27,6 @@ import {
|
|||
CONNECTION_RUNTIME_TOOL_NAMES,
|
||||
ISSUE_CONTINUATION_SUMMARY_DOCUMENT_KEY,
|
||||
ISSUE_DISPOSITION_REPAIR_RETRY_REASON,
|
||||
MODEL_PROFILE_KEYS,
|
||||
PROVIDER_QUOTA_MONITOR_SERVICE_NAME,
|
||||
envBindingSchema,
|
||||
isEnvironmentDriverSupportedForAdapter,
|
||||
|
|
@ -41,7 +40,6 @@ import {
|
|||
type IssueExecutionMonitorClearReason,
|
||||
type IssueExecutionMonitorPolicy,
|
||||
type IssueExecutionMonitorRecoveryPolicy,
|
||||
type ModelProfileKey,
|
||||
type RequestConfirmationResult,
|
||||
type RoutineRevisionSnapshotV1,
|
||||
type RunLivenessState,
|
||||
|
|
@ -151,13 +149,11 @@ import {
|
|||
} from "./provider-trace-store.js";
|
||||
import {
|
||||
getServerAdapter,
|
||||
listAdapterModelProfiles,
|
||||
runningProcesses,
|
||||
} from "../adapters/index.js";
|
||||
import type {
|
||||
AdapterExecutionResult,
|
||||
AdapterInvocationMeta,
|
||||
AdapterModelProfileDefinition,
|
||||
AdapterRuntimeEvent,
|
||||
AdapterRuntimeMcpAccess,
|
||||
AdapterRuntimeMcpServer,
|
||||
|
|
@ -337,10 +333,7 @@ import {
|
|||
buildImmediateExecutionPathRecoveryNoticeSeed,
|
||||
buildWorkspaceValidationRecoveryNoticeSeed,
|
||||
} from "./recovery/stranded-notice.js";
|
||||
import {
|
||||
recoveryAssigneeAdapterOverrides,
|
||||
withRecoveryModelProfileHint,
|
||||
} from "./recovery/model-profile-hint.js";
|
||||
import { withRecoveryContext } from "./recovery/status-only-context.js";
|
||||
import {
|
||||
ACTIVE_RUN_OUTPUT_SUSPICION_THRESHOLD_MS as RECOVERY_ACTIVE_RUN_OUTPUT_SUSPICION_THRESHOLD_MS,
|
||||
recoveryService,
|
||||
|
|
@ -3191,23 +3184,10 @@ type SessionCompactionDecision = {
|
|||
};
|
||||
|
||||
interface ParsedIssueAssigneeAdapterOverrides {
|
||||
modelProfile: ModelProfileKey | null;
|
||||
adapterConfig: Record<string, unknown> | null;
|
||||
useProjectWorkspace: boolean | null;
|
||||
}
|
||||
|
||||
type ModelProfileRequestSource = "issue_override" | "wake_context";
|
||||
type AppliedModelProfileConfigSource = "agent_runtime" | "adapter_default";
|
||||
|
||||
export interface ModelProfileApplication {
|
||||
requested: ModelProfileKey | null;
|
||||
requestedBy: ModelProfileRequestSource | null;
|
||||
applied: ModelProfileKey | null;
|
||||
configSource: AppliedModelProfileConfigSource | null;
|
||||
fallbackReason: string | null;
|
||||
adapterConfig: Record<string, unknown> | null;
|
||||
}
|
||||
|
||||
/**
|
||||
* A single read-only referenced (mentioned) project workspace resolved for a run.
|
||||
* The run materializes one entry per authorized additional project, each in its own
|
||||
|
|
@ -4482,165 +4462,6 @@ export async function createManagedMcpRunConfig(input: {
|
|||
};
|
||||
}
|
||||
|
||||
function readModelProfileKey(value: unknown): ModelProfileKey | null {
|
||||
return MODEL_PROFILE_KEYS.includes(value as ModelProfileKey)
|
||||
? (value as ModelProfileKey)
|
||||
: null;
|
||||
}
|
||||
|
||||
function readContextModelProfile(
|
||||
contextSnapshot: Record<string, unknown> | null | undefined,
|
||||
): ModelProfileKey | null {
|
||||
return readModelProfileKey(contextSnapshot?.modelProfile);
|
||||
}
|
||||
|
||||
export function normalizeModelProfileWakeContext(input: {
|
||||
contextSnapshot: Record<string, unknown>;
|
||||
payload: Record<string, unknown> | null | undefined;
|
||||
}): Record<string, unknown> {
|
||||
const modelProfileFromPayload = readModelProfileKey(
|
||||
input.payload?.modelProfile,
|
||||
);
|
||||
if (
|
||||
!readContextModelProfile(input.contextSnapshot) &&
|
||||
modelProfileFromPayload
|
||||
) {
|
||||
input.contextSnapshot.modelProfile = modelProfileFromPayload;
|
||||
}
|
||||
return input.contextSnapshot;
|
||||
}
|
||||
|
||||
function readAgentRuntimeModelProfile(
|
||||
runtimeConfig: unknown,
|
||||
key: ModelProfileKey,
|
||||
): {
|
||||
enabled: boolean;
|
||||
adapterConfig: Record<string, unknown>;
|
||||
configured: boolean;
|
||||
} {
|
||||
const modelProfiles = parseObject(parseObject(runtimeConfig).modelProfiles);
|
||||
const profile = parseObject(modelProfiles[key]);
|
||||
if (Object.keys(profile).length === 0) {
|
||||
return { enabled: true, adapterConfig: {}, configured: false };
|
||||
}
|
||||
|
||||
return {
|
||||
enabled: profile.enabled !== false,
|
||||
adapterConfig: parseObject(profile.adapterConfig),
|
||||
configured: true,
|
||||
};
|
||||
}
|
||||
|
||||
export function resolveModelProfileApplication(input: {
|
||||
adapterModelProfiles: AdapterModelProfileDefinition[];
|
||||
agentRuntimeConfig: unknown;
|
||||
issueModelProfile: ModelProfileKey | null | undefined;
|
||||
contextSnapshot: Record<string, unknown> | null | undefined;
|
||||
profileResolutionFallbackReason?: string | null;
|
||||
}): ModelProfileApplication {
|
||||
const issueModelProfile = input.issueModelProfile ?? null;
|
||||
const contextModelProfile = readContextModelProfile(input.contextSnapshot);
|
||||
const requested = issueModelProfile ?? contextModelProfile;
|
||||
const requestedBy: ModelProfileRequestSource | null = issueModelProfile
|
||||
? "issue_override"
|
||||
: contextModelProfile
|
||||
? "wake_context"
|
||||
: null;
|
||||
|
||||
if (!requested) {
|
||||
return {
|
||||
requested: null,
|
||||
requestedBy: null,
|
||||
applied: null,
|
||||
configSource: null,
|
||||
fallbackReason: null,
|
||||
adapterConfig: null,
|
||||
};
|
||||
}
|
||||
|
||||
const adapterProfile =
|
||||
input.adapterModelProfiles.find((profile) => profile.key === requested) ??
|
||||
null;
|
||||
if (!adapterProfile) {
|
||||
return {
|
||||
requested,
|
||||
requestedBy,
|
||||
applied: null,
|
||||
configSource: null,
|
||||
fallbackReason:
|
||||
input.profileResolutionFallbackReason ??
|
||||
"adapter_profile_not_supported",
|
||||
adapterConfig: null,
|
||||
};
|
||||
}
|
||||
|
||||
const runtimeProfile = readAgentRuntimeModelProfile(
|
||||
input.agentRuntimeConfig,
|
||||
requested,
|
||||
);
|
||||
if (!runtimeProfile.enabled) {
|
||||
return {
|
||||
requested,
|
||||
requestedBy,
|
||||
applied: null,
|
||||
configSource: null,
|
||||
fallbackReason: "agent_runtime_profile_disabled",
|
||||
adapterConfig: null,
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
requested,
|
||||
requestedBy,
|
||||
applied: requested,
|
||||
configSource: runtimeProfile.configured
|
||||
? "agent_runtime"
|
||||
: "adapter_default",
|
||||
fallbackReason: null,
|
||||
adapterConfig: {
|
||||
...parseObject(adapterProfile.adapterConfig),
|
||||
...runtimeProfile.adapterConfig,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
export function mergeModelProfileAdapterConfig(input: {
|
||||
baseConfig: Record<string, unknown>;
|
||||
modelProfile: ModelProfileApplication;
|
||||
issueAdapterConfig: Record<string, unknown> | null | undefined;
|
||||
}): Record<string, unknown> {
|
||||
return {
|
||||
...input.baseConfig,
|
||||
...(input.modelProfile.adapterConfig ?? {}),
|
||||
...(input.issueAdapterConfig ?? {}),
|
||||
};
|
||||
}
|
||||
|
||||
function modelProfileRunMetadata(
|
||||
modelProfile: ModelProfileApplication,
|
||||
): Record<string, unknown> | null {
|
||||
if (!modelProfile.requested) return null;
|
||||
return {
|
||||
requested: modelProfile.requested,
|
||||
requestedBy: modelProfile.requestedBy,
|
||||
applied: modelProfile.applied,
|
||||
configSource: modelProfile.configSource,
|
||||
fallbackReason: modelProfile.fallbackReason,
|
||||
};
|
||||
}
|
||||
|
||||
function mergeModelProfileRunMetadata(
|
||||
resultJson: Record<string, unknown> | null,
|
||||
modelProfile: ModelProfileApplication,
|
||||
): Record<string, unknown> | null {
|
||||
const metadata = modelProfileRunMetadata(modelProfile);
|
||||
if (!metadata) return resultJson;
|
||||
return {
|
||||
...(resultJson ?? {}),
|
||||
modelProfile: metadata,
|
||||
};
|
||||
}
|
||||
|
||||
export function summarizeHeartbeatRunContextSnapshot(
|
||||
contextSnapshot: Record<string, unknown> | null | undefined,
|
||||
): Record<string, unknown> | null {
|
||||
|
|
@ -4654,7 +4475,6 @@ export function summarizeHeartbeatRunContextSnapshot(
|
|||
"wakeReason",
|
||||
"wakeSource",
|
||||
"wakeTriggerDetail",
|
||||
"modelProfile",
|
||||
] as const;
|
||||
|
||||
for (const key of allowedKeys) {
|
||||
|
|
@ -5109,11 +4929,6 @@ function parseIssueAssigneeAdapterOverrides(
|
|||
raw: unknown,
|
||||
): ParsedIssueAssigneeAdapterOverrides | null {
|
||||
const parsed = parseObject(raw);
|
||||
const modelProfile = MODEL_PROFILE_KEYS.includes(
|
||||
parsed.modelProfile as ModelProfileKey,
|
||||
)
|
||||
? (parsed.modelProfile as ModelProfileKey)
|
||||
: null;
|
||||
const parsedAdapterConfig = parseObject(parsed.adapterConfig);
|
||||
const adapterConfig =
|
||||
Object.keys(parsedAdapterConfig).length > 0 ? parsedAdapterConfig : null;
|
||||
|
|
@ -5121,10 +4936,9 @@ function parseIssueAssigneeAdapterOverrides(
|
|||
typeof parsed.useProjectWorkspace === "boolean"
|
||||
? parsed.useProjectWorkspace
|
||||
: null;
|
||||
if (!modelProfile && !adapterConfig && useProjectWorkspace === null)
|
||||
if (!adapterConfig && useProjectWorkspace === null)
|
||||
return null;
|
||||
return {
|
||||
modelProfile,
|
||||
adapterConfig,
|
||||
useProjectWorkspace,
|
||||
};
|
||||
|
|
@ -5372,7 +5186,6 @@ const EFFECTIVE_RUN_SESSION_CONFIG_CATEGORIES = [
|
|||
"adapter",
|
||||
"adapterConfig",
|
||||
"agentRuntimeConfig",
|
||||
"modelProfile",
|
||||
"instructions",
|
||||
"issueOverrides",
|
||||
"workspaceConfig",
|
||||
|
|
@ -5645,7 +5458,6 @@ const EFFECTIVE_RUN_SESSION_CONFIG_CATEGORY_LABELS: Record<
|
|||
adapter: "adapter",
|
||||
adapterConfig: "adapter config",
|
||||
agentRuntimeConfig: "agent runtime config",
|
||||
modelProfile: "model profile",
|
||||
instructions: "instructions",
|
||||
issueOverrides: "issue overrides",
|
||||
workspaceConfig: "workspace config",
|
||||
|
|
@ -6020,7 +5832,6 @@ function buildSessionConfigCategoryValues(input: {
|
|||
adapterType: string;
|
||||
effectiveAdapterConfig: Record<string, unknown>;
|
||||
agentRuntimeConfig: unknown;
|
||||
modelProfile: unknown;
|
||||
instructions: unknown;
|
||||
issueOverrides: unknown;
|
||||
workspaceConfig: unknown;
|
||||
|
|
@ -6048,7 +5859,6 @@ function buildSessionConfigCategoryValues(input: {
|
|||
},
|
||||
adapterConfig: input.effectiveAdapterConfig,
|
||||
agentRuntimeConfig: input.agentRuntimeConfig,
|
||||
modelProfile: input.modelProfile,
|
||||
instructions: input.instructions,
|
||||
issueOverrides: input.issueOverrides,
|
||||
workspaceConfig,
|
||||
|
|
@ -6067,7 +5877,6 @@ export async function buildEffectiveRunSessionConfigMetadata(input: {
|
|||
adapterType: string;
|
||||
effectiveAdapterConfig: Record<string, unknown>;
|
||||
agentRuntimeConfig: unknown;
|
||||
modelProfile: unknown;
|
||||
issueOverrides: unknown;
|
||||
workspaceConfig: unknown;
|
||||
environment: unknown;
|
||||
|
|
@ -6086,7 +5895,6 @@ export async function buildEffectiveRunSessionConfigMetadata(input: {
|
|||
adapterType: input.adapterType,
|
||||
effectiveAdapterConfig: input.effectiveAdapterConfig,
|
||||
agentRuntimeConfig: input.agentRuntimeConfig,
|
||||
modelProfile: input.modelProfile,
|
||||
instructions,
|
||||
issueOverrides: input.issueOverrides,
|
||||
workspaceConfig: input.workspaceConfig,
|
||||
|
|
@ -6662,7 +6470,6 @@ function enrichWakeContextSnapshot(input: {
|
|||
) {
|
||||
contextSnapshot.wakeTriggerDetail = triggerDetail;
|
||||
}
|
||||
normalizeModelProfileWakeContext({ contextSnapshot, payload });
|
||||
normalizeInteractionContinuationWakeContext(contextSnapshot, payload);
|
||||
|
||||
return {
|
||||
|
|
@ -9479,8 +9286,6 @@ export function heartbeatService(
|
|||
projectId: input.claimed.projectId,
|
||||
goalId: input.claimed.goalId,
|
||||
assigneeAgentId: input.claimed.assigneeAgentId,
|
||||
assigneeAdapterOverrides:
|
||||
recoveryAssigneeAdapterOverrides("status_only"),
|
||||
originKind: RECOVERY_ORIGIN_KINDS.strandedIssueRecovery,
|
||||
originId: input.claimed.id,
|
||||
originFingerprint: `issue_monitor:${input.clearReason}`,
|
||||
|
|
@ -9494,13 +9299,13 @@ export function heartbeatService(
|
|||
triggerDetail: "system",
|
||||
reason: "issue_monitor_recovery_issue",
|
||||
idempotencyKey: `issue-monitor-recovery-issue:${input.claimed.id}:${input.clearReason}:${input.scheduledAtIso}`,
|
||||
payload: withRecoveryModelProfileHint(
|
||||
payload: withRecoveryContext(
|
||||
{ issueId: recoveryIssue.id, sourceIssueId: input.claimed.id },
|
||||
"status_only",
|
||||
),
|
||||
requestedByActorType: input.actorType,
|
||||
requestedByActorId: input.actorId,
|
||||
contextSnapshot: withRecoveryModelProfileHint(
|
||||
contextSnapshot: withRecoveryContext(
|
||||
{
|
||||
issueId: recoveryIssue.id,
|
||||
sourceIssueId: input.claimed.id,
|
||||
|
|
@ -9561,7 +9366,7 @@ export function heartbeatService(
|
|||
triggerDetail: "system",
|
||||
reason: "issue_monitor_recovery",
|
||||
idempotencyKey: `issue-monitor-recovery:${input.claimed.id}:${input.clearReason}:${input.scheduledAtIso}`,
|
||||
payload: withRecoveryModelProfileHint(
|
||||
payload: withRecoveryContext(
|
||||
{
|
||||
issueId: input.claimed.id,
|
||||
monitorAttemptCount: input.nextAttemptCount,
|
||||
|
|
@ -9576,7 +9381,7 @@ export function heartbeatService(
|
|||
),
|
||||
requestedByActorType: input.actorType,
|
||||
requestedByActorId: input.actorId,
|
||||
contextSnapshot: withRecoveryModelProfileHint(
|
||||
contextSnapshot: withRecoveryContext(
|
||||
{
|
||||
issueId: input.claimed.id,
|
||||
source: "issue.monitor.recovery",
|
||||
|
|
@ -11923,7 +11728,7 @@ export function heartbeatService(
|
|||
const contextSnapshot = parseObject(run.contextSnapshot);
|
||||
const taskKey = deriveTaskKeyWithHeartbeatFallback(contextSnapshot, null);
|
||||
const sessionBefore = await resolveSessionBeforeForWakeup(agent, taskKey);
|
||||
const retryContextSnapshot = withRecoveryModelProfileHint(
|
||||
const retryContextSnapshot = withRecoveryContext(
|
||||
{
|
||||
...contextSnapshot,
|
||||
retryOfRunId: run.id,
|
||||
|
|
@ -11964,7 +11769,7 @@ export function heartbeatService(
|
|||
source: "automation",
|
||||
triggerDetail: "system",
|
||||
reason: "missing_issue_comment",
|
||||
payload: withRecoveryModelProfileHint(
|
||||
payload: withRecoveryContext(
|
||||
{
|
||||
issueId,
|
||||
retryOfRunId: run.id,
|
||||
|
|
@ -12302,7 +12107,7 @@ export function heartbeatService(
|
|||
: "process_lost";
|
||||
const taskKey = deriveTaskKeyWithHeartbeatFallback(contextSnapshot, null);
|
||||
const sessionBefore = await resolveSessionBeforeForWakeup(agent, taskKey);
|
||||
const retryContextSnapshot = withRecoveryModelProfileHint(
|
||||
const retryContextSnapshot = withRecoveryContext(
|
||||
{
|
||||
...contextSnapshot,
|
||||
retryOfRunId: run.id,
|
||||
|
|
@ -12325,7 +12130,7 @@ export function heartbeatService(
|
|||
source: "automation",
|
||||
triggerDetail: "system",
|
||||
reason: "process_lost_retry",
|
||||
payload: withRecoveryModelProfileHint(
|
||||
payload: withRecoveryContext(
|
||||
{
|
||||
...(issueId ? { issueId } : {}),
|
||||
retryOfRunId: run.id,
|
||||
|
|
@ -13686,7 +13491,7 @@ export function heartbeatService(
|
|||
workspaceValidationRetryPayload !== null &&
|
||||
Object.keys(workspaceValidationRetryPayload).length > 0;
|
||||
const retryContextSnapshot: Record<string, unknown> =
|
||||
withRecoveryModelProfileHint(
|
||||
withRecoveryContext(
|
||||
{
|
||||
...contextSnapshot,
|
||||
retryOfRunId: run.id,
|
||||
|
|
@ -13993,7 +13798,7 @@ export function heartbeatService(
|
|||
source: "automation",
|
||||
triggerDetail: "system",
|
||||
reason: wakeReason,
|
||||
payload: withRecoveryModelProfileHint(
|
||||
payload: withRecoveryContext(
|
||||
{
|
||||
...(issueId ? { issueId } : {}),
|
||||
retryOfRunId: run.id,
|
||||
|
|
@ -18254,47 +18059,10 @@ export function heartbeatService(
|
|||
legacyUseProjectWorkspace:
|
||||
issueAssigneeOverrides?.useProjectWorkspace ?? null,
|
||||
});
|
||||
let adapterModelProfiles: AdapterModelProfileDefinition[] = [];
|
||||
let profileResolutionFallbackReason: string | null = null;
|
||||
try {
|
||||
adapterModelProfiles = await listAdapterModelProfiles(
|
||||
agent.adapterType,
|
||||
);
|
||||
} catch (error) {
|
||||
profileResolutionFallbackReason = "adapter_profile_resolution_failed";
|
||||
logger.warn(
|
||||
{
|
||||
err: error,
|
||||
companyId: agent.companyId,
|
||||
agentId: agent.id,
|
||||
adapterType: agent.adapterType,
|
||||
runId: run.id,
|
||||
},
|
||||
"Failed to resolve adapter model profiles; falling back to primary adapter config",
|
||||
);
|
||||
}
|
||||
const modelProfileApplication = resolveModelProfileApplication({
|
||||
adapterModelProfiles,
|
||||
agentRuntimeConfig: agent.runtimeConfig,
|
||||
issueModelProfile: issueAssigneeOverrides?.modelProfile ?? null,
|
||||
contextSnapshot: context,
|
||||
profileResolutionFallbackReason,
|
||||
});
|
||||
const modelProfileMetadata = modelProfileRunMetadata(
|
||||
modelProfileApplication,
|
||||
);
|
||||
if (modelProfileMetadata) {
|
||||
context.paperclipModelProfile = modelProfileMetadata;
|
||||
if (modelProfileApplication.requested)
|
||||
context.modelProfile = modelProfileApplication.requested;
|
||||
} else {
|
||||
delete context.paperclipModelProfile;
|
||||
}
|
||||
const mergedConfig = mergeModelProfileAdapterConfig({
|
||||
baseConfig: workspaceManagedConfig,
|
||||
modelProfile: modelProfileApplication,
|
||||
issueAdapterConfig: issueAssigneeOverrides?.adapterConfig ?? null,
|
||||
});
|
||||
const mergedConfig = {
|
||||
...workspaceManagedConfig,
|
||||
...(issueAssigneeOverrides?.adapterConfig ?? {}),
|
||||
};
|
||||
const configSnapshot = buildExecutionWorkspaceConfigSnapshot(
|
||||
mergedConfig,
|
||||
selectedEnvironmentId,
|
||||
|
|
@ -18386,7 +18154,6 @@ export function heartbeatService(
|
|||
adapterType: agent.adapterType,
|
||||
effectiveAdapterConfig: runtimeConfig,
|
||||
agentRuntimeConfig: agent.runtimeConfig,
|
||||
modelProfile: modelProfileMetadata,
|
||||
issueOverrides: issueAssigneeOverrides,
|
||||
workspaceConfig: {
|
||||
requestedMode: requestedExecutionWorkspaceMode,
|
||||
|
|
@ -19827,20 +19594,12 @@ export function heartbeatService(
|
|||
if (key in meta.env) meta.env[key] = "***REDACTED***";
|
||||
}
|
||||
}
|
||||
const modelProfileMetadata = modelProfileRunMetadata(
|
||||
modelProfileApplication,
|
||||
);
|
||||
await appendRunEvent(currentRun, {
|
||||
eventType: "adapter.invoke",
|
||||
stream: "system",
|
||||
level: "info",
|
||||
message: "adapter invocation",
|
||||
payload: {
|
||||
...(meta as unknown as Record<string, unknown>),
|
||||
...(modelProfileMetadata
|
||||
? { modelProfile: modelProfileMetadata }
|
||||
: {}),
|
||||
},
|
||||
payload: meta as unknown as Record<string, unknown>,
|
||||
});
|
||||
};
|
||||
|
||||
|
|
@ -21152,20 +20911,17 @@ export function heartbeatService(
|
|||
|
||||
const persistedResultJson = mergeHeartbeatRunResultJson(
|
||||
mergeRunStopMetadataForAgent(agent, outcome, {
|
||||
resultJson: mergeModelProfileRunMetadata(
|
||||
mergeAdapterRecoveryMetadata({
|
||||
resultJson: {
|
||||
...(adapterResult.nativeFinalization
|
||||
? parseObject(latestRun?.resultJson)
|
||||
: {}),
|
||||
...parseObject(adapterResult.resultJson),
|
||||
configFreshness: configFreshnessResultMetadata,
|
||||
},
|
||||
errorFamily: adapterResult.errorFamily ?? null,
|
||||
retryNotBefore: adapterResult.retryNotBefore ?? null,
|
||||
}),
|
||||
modelProfileApplication,
|
||||
),
|
||||
resultJson: mergeAdapterRecoveryMetadata({
|
||||
resultJson: {
|
||||
...(adapterResult.nativeFinalization
|
||||
? parseObject(latestRun?.resultJson)
|
||||
: {}),
|
||||
...parseObject(adapterResult.resultJson),
|
||||
configFreshness: configFreshnessResultMetadata,
|
||||
},
|
||||
errorFamily: adapterResult.errorFamily ?? null,
|
||||
retryNotBefore: adapterResult.retryNotBefore ?? null,
|
||||
}),
|
||||
errorCode: runErrorCode,
|
||||
errorMessage: runErrorMessage,
|
||||
}),
|
||||
|
|
@ -22685,7 +22441,7 @@ export function heartbeatService(
|
|||
source: "automation",
|
||||
triggerDetail: "system",
|
||||
reason: EXECUTION_REVIEW_PARTICIPANT_RECOVERY_WAKE_REASON,
|
||||
payload: withRecoveryModelProfileHint(
|
||||
payload: withRecoveryContext(
|
||||
{
|
||||
issueId: issue.id,
|
||||
retryOfRunId: run.id,
|
||||
|
|
@ -22712,7 +22468,7 @@ export function heartbeatService(
|
|||
triggerDetail: "system",
|
||||
status: "queued",
|
||||
wakeupRequestId: wakeupRequest.id,
|
||||
contextSnapshot: withRecoveryModelProfileHint(
|
||||
contextSnapshot: withRecoveryContext(
|
||||
{
|
||||
issueId: issue.id,
|
||||
taskId: issue.id,
|
||||
|
|
@ -22856,7 +22612,7 @@ export function heartbeatService(
|
|||
? "issue.assignment_recovery"
|
||||
: "issue.continuation_recovery";
|
||||
const now = new Date();
|
||||
const recoveryContextSnapshot = withRecoveryModelProfileHint(
|
||||
const recoveryContextSnapshot = withRecoveryContext(
|
||||
{
|
||||
issueId: issue.id,
|
||||
taskId: issue.id,
|
||||
|
|
@ -22903,7 +22659,7 @@ export function heartbeatService(
|
|||
source: "automation",
|
||||
triggerDetail: "system",
|
||||
reason: recoveryReason,
|
||||
payload: withRecoveryModelProfileHint(
|
||||
payload: withRecoveryContext(
|
||||
{
|
||||
issueId: issue.id,
|
||||
retryOfRunId: run.id,
|
||||
|
|
|
|||
|
|
@ -16,10 +16,7 @@ import { logActivity } from "./activity-log.js";
|
|||
import { budgetService } from "./budgets.js";
|
||||
import { issueService } from "./issues.js";
|
||||
import { visibleIssueCondition } from "./issue-visibility.js";
|
||||
import {
|
||||
recoveryAssigneeAdapterOverrides,
|
||||
withRecoveryModelProfileHint,
|
||||
} from "./recovery/model-profile-hint.js";
|
||||
import { withRecoveryContext } from "./recovery/status-only-context.js";
|
||||
import { RECOVERY_ORIGIN_KINDS } from "./recovery/origins.js";
|
||||
|
||||
export const PRODUCTIVITY_REVIEW_ORIGIN_KIND = RECOVERY_ORIGIN_KINDS.issueProductivityReview;
|
||||
|
|
@ -771,7 +768,6 @@ export function productivityReviewService(db: Db, deps?: { enqueueWakeup?: Enque
|
|||
goalId: evidence.sourceIssue.goalId,
|
||||
billingCode: evidence.sourceIssue.billingCode,
|
||||
assigneeAgentId: ownerAgentId,
|
||||
assigneeAdapterOverrides: recoveryAssigneeAdapterOverrides("status_only"),
|
||||
originKind: PRODUCTIVITY_REVIEW_ORIGIN_KIND,
|
||||
originId: evidence.sourceIssue.id,
|
||||
originFingerprint: productivityReviewFingerprint(evidence.sourceIssue.id),
|
||||
|
|
@ -817,14 +813,14 @@ export function productivityReviewService(db: Db, deps?: { enqueueWakeup?: Enque
|
|||
source: "assignment",
|
||||
triggerDetail: "system",
|
||||
reason: "issue_assigned",
|
||||
payload: withRecoveryModelProfileHint({
|
||||
payload: withRecoveryContext({
|
||||
issueId: review.id,
|
||||
sourceIssueId: evidence.sourceIssue.id,
|
||||
trigger: evidence.trigger,
|
||||
}, "status_only"),
|
||||
requestedByActorType: "system",
|
||||
requestedByActorId: "productivity_review",
|
||||
contextSnapshot: withRecoveryModelProfileHint({
|
||||
contextSnapshot: withRecoveryContext({
|
||||
issueId: review.id,
|
||||
taskId: review.id,
|
||||
wakeReason: "issue_assigned",
|
||||
|
|
|
|||
|
|
@ -1,44 +0,0 @@
|
|||
import { describe, expect, it } from "vitest";
|
||||
import {
|
||||
recoveryAssigneeAdapterOverrides,
|
||||
scrubRecoveryModelProfileHints,
|
||||
withRecoveryModelProfileHint,
|
||||
} from "./model-profile-hint.js";
|
||||
|
||||
describe("recovery model profile policy", () => {
|
||||
it("allows cheap only for status-only recovery and adds guard context", () => {
|
||||
expect(withRecoveryModelProfileHint({ issueId: "issue-1" }, "status_only")).toEqual({
|
||||
issueId: "issue-1",
|
||||
recoveryIntent: "status_only",
|
||||
allowDeliverableWork: false,
|
||||
allowDocumentUpdates: false,
|
||||
resumeRequiresNormalModel: true,
|
||||
modelProfile: "cheap",
|
||||
});
|
||||
expect(recoveryAssigneeAdapterOverrides("status_only")).toEqual({ modelProfile: "cheap" });
|
||||
});
|
||||
|
||||
it("scrubs inherited cheap hints from normal model source-work retries", () => {
|
||||
expect(withRecoveryModelProfileHint({
|
||||
issueId: "issue-1",
|
||||
retryOfRunId: "run-1",
|
||||
modelProfile: "cheap",
|
||||
recoveryIntent: "status_only",
|
||||
allowDeliverableWork: false,
|
||||
allowDocumentUpdates: false,
|
||||
resumeRequiresNormalModel: true,
|
||||
}, "normal_model")).toEqual({
|
||||
issueId: "issue-1",
|
||||
retryOfRunId: "run-1",
|
||||
});
|
||||
});
|
||||
|
||||
it("can scrub copied downstream source-work contexts without applying a profile", () => {
|
||||
expect(scrubRecoveryModelProfileHints({
|
||||
taskId: "source-task",
|
||||
modelProfile: "cheap",
|
||||
paperclipModelProfile: { requested: "cheap" },
|
||||
allowDocumentUpdates: false,
|
||||
})).toEqual({ taskId: "source-task" });
|
||||
});
|
||||
});
|
||||
|
|
@ -1,65 +0,0 @@
|
|||
export const RECOVERY_MODEL_PROFILE_KEY = "cheap" as const;
|
||||
|
||||
export type RecoveryModelProfileWorkClass = "status_only" | "normal_model";
|
||||
|
||||
export const STATUS_ONLY_RECOVERY_GUARD_CONTEXT = {
|
||||
recoveryIntent: "status_only",
|
||||
allowDeliverableWork: false,
|
||||
allowDocumentUpdates: false,
|
||||
resumeRequiresNormalModel: true,
|
||||
} as const;
|
||||
|
||||
const RECOVERY_MODEL_PROFILE_HINT_KEYS = [
|
||||
"modelProfile",
|
||||
"paperclipModelProfile",
|
||||
"recoveryIntent",
|
||||
"allowDeliverableWork",
|
||||
"allowDocumentUpdates",
|
||||
"resumeRequiresNormalModel",
|
||||
] as const;
|
||||
|
||||
type RecoveryModelProfileHintKey = (typeof RECOVERY_MODEL_PROFILE_HINT_KEYS)[number];
|
||||
type WithoutRecoveryModelProfileHints<T> = Omit<T, RecoveryModelProfileHintKey>;
|
||||
|
||||
export function scrubRecoveryModelProfileHints<T extends Record<string, unknown>>(
|
||||
input: T,
|
||||
): WithoutRecoveryModelProfileHints<T> {
|
||||
const output: Record<string, unknown> = { ...input };
|
||||
for (const key of RECOVERY_MODEL_PROFILE_HINT_KEYS) {
|
||||
delete output[key];
|
||||
}
|
||||
return output as WithoutRecoveryModelProfileHints<T>;
|
||||
}
|
||||
|
||||
export function withRecoveryModelProfileHint<T extends Record<string, unknown>>(
|
||||
input: T,
|
||||
workClass: "normal_model",
|
||||
): WithoutRecoveryModelProfileHints<T>;
|
||||
export function withRecoveryModelProfileHint<T extends Record<string, unknown>>(
|
||||
input: T,
|
||||
workClass: "status_only",
|
||||
): WithoutRecoveryModelProfileHints<T> & typeof STATUS_ONLY_RECOVERY_GUARD_CONTEXT & {
|
||||
modelProfile: typeof RECOVERY_MODEL_PROFILE_KEY;
|
||||
};
|
||||
export function withRecoveryModelProfileHint<T extends Record<string, unknown>>(
|
||||
input: T,
|
||||
workClass: RecoveryModelProfileWorkClass,
|
||||
):
|
||||
| WithoutRecoveryModelProfileHints<T>
|
||||
| (WithoutRecoveryModelProfileHints<T> & typeof STATUS_ONLY_RECOVERY_GUARD_CONTEXT & {
|
||||
modelProfile: typeof RECOVERY_MODEL_PROFILE_KEY;
|
||||
}) {
|
||||
if (workClass === "normal_model") {
|
||||
return scrubRecoveryModelProfileHints(input);
|
||||
}
|
||||
|
||||
return {
|
||||
...scrubRecoveryModelProfileHints(input),
|
||||
...STATUS_ONLY_RECOVERY_GUARD_CONTEXT,
|
||||
modelProfile: RECOVERY_MODEL_PROFILE_KEY,
|
||||
};
|
||||
}
|
||||
|
||||
export function recoveryAssigneeAdapterOverrides(_workClass: Extract<RecoveryModelProfileWorkClass, "status_only">) {
|
||||
return { modelProfile: RECOVERY_MODEL_PROFILE_KEY };
|
||||
}
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
import { createHash } from "node:crypto";
|
||||
import type { IssueReviewAttention } from "@paperclipai/shared";
|
||||
import { withRecoveryModelProfileHint } from "./model-profile-hint.js";
|
||||
import { withRecoveryContext } from "./status-only-context.js";
|
||||
|
||||
export const ISSUE_REVIEW_PATH_LOST_WAKE_REASON = "issue_review_path_lost";
|
||||
export const REVIEW_PATH_RECOVERY_INSTRUCTION =
|
||||
|
|
@ -100,7 +100,7 @@ export function decideIssueReviewPathRecovery(input: {
|
|||
});
|
||||
if (input.existingWake) return { kind: "skip", reason: "review-path recovery wake already exists" };
|
||||
|
||||
const payload = withRecoveryModelProfileHint({
|
||||
const payload = withRecoveryContext({
|
||||
issueId: input.issueId,
|
||||
taskId: input.issueId,
|
||||
sourceIssueId: input.issueId,
|
||||
|
|
@ -116,7 +116,7 @@ export function decideIssueReviewPathRecovery(input: {
|
|||
kind: "enqueue",
|
||||
idempotencyKey,
|
||||
payload,
|
||||
contextSnapshot: withRecoveryModelProfileHint({
|
||||
contextSnapshot: withRecoveryContext({
|
||||
...payload,
|
||||
wakeReason: ISSUE_REVIEW_PATH_LOST_WAKE_REASON,
|
||||
source: readNonEmptyString(context.source) ?? "heartbeat.review_path_disposition",
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import { and, eq, inArray } from "drizzle-orm";
|
|||
import type { Db } from "@paperclipai/db";
|
||||
import { agentWakeupRequests, agents, heartbeatRuns, issues } from "@paperclipai/db";
|
||||
import type { RunLivenessState } from "@paperclipai/shared";
|
||||
import { withRecoveryModelProfileHint } from "./model-profile-hint.js";
|
||||
import { withRecoveryContext } from "./status-only-context.js";
|
||||
import { RECOVERY_REASON_KINDS } from "./origins.js";
|
||||
|
||||
export const RUN_LIVENESS_CONTINUATION_REASON = RECOVERY_REASON_KINDS.runLivenessContinuation;
|
||||
|
|
@ -156,7 +156,7 @@ export function decideRunLivenessContinuation(input: {
|
|||
return { kind: "skip", reason: "continuation wake already exists for this source run and attempt" };
|
||||
}
|
||||
|
||||
const payload = withRecoveryModelProfileHint({
|
||||
const payload = withRecoveryContext({
|
||||
issueId: issue.id,
|
||||
sourceRunId: run.id,
|
||||
livenessState,
|
||||
|
|
@ -173,7 +173,7 @@ export function decideRunLivenessContinuation(input: {
|
|||
nextAttempt,
|
||||
idempotencyKey,
|
||||
payload,
|
||||
contextSnapshot: withRecoveryModelProfileHint({
|
||||
contextSnapshot: withRecoveryContext({
|
||||
issueId: issue.id,
|
||||
taskId: issue.id,
|
||||
taskKey: issue.id,
|
||||
|
|
|
|||
|
|
@ -68,10 +68,7 @@ import {
|
|||
RECOVERY_ORIGIN_KINDS,
|
||||
isStrandedIssueRecoveryOriginKind,
|
||||
} from "./origins.js";
|
||||
import {
|
||||
recoveryAssigneeAdapterOverrides,
|
||||
withRecoveryModelProfileHint,
|
||||
} from "./model-profile-hint.js";
|
||||
import { withRecoveryContext } from "./status-only-context.js";
|
||||
import { isAutomaticRecoverySuppressedByPauseHold } from "./pause-hold-guard.js";
|
||||
import {
|
||||
collectDispositionRepairSourceState,
|
||||
|
|
@ -1034,14 +1031,14 @@ export function recoveryService(db: Db, deps: { enqueueWakeup: RecoveryWakeup })
|
|||
source: "automation",
|
||||
triggerDetail: "system",
|
||||
reason: input.reason,
|
||||
payload: withRecoveryModelProfileHint({
|
||||
payload: withRecoveryContext({
|
||||
issueId: input.issueId,
|
||||
...(input.retryOfRunId ? { retryOfRunId: input.retryOfRunId } : {}),
|
||||
...(input.extraContext ?? {}),
|
||||
}, "normal_model"),
|
||||
requestedByActorType: "system",
|
||||
requestedByActorId: null,
|
||||
contextSnapshot: withRecoveryModelProfileHint({
|
||||
contextSnapshot: withRecoveryContext({
|
||||
issueId: input.issueId,
|
||||
taskId: input.issueId,
|
||||
wakeReason: input.reason,
|
||||
|
|
@ -1072,13 +1069,13 @@ export function recoveryService(db: Db, deps: { enqueueWakeup: RecoveryWakeup })
|
|||
source: "assignment",
|
||||
triggerDetail: "system",
|
||||
reason: "issue_assigned",
|
||||
payload: withRecoveryModelProfileHint({
|
||||
payload: withRecoveryContext({
|
||||
issueId: issue.id,
|
||||
mutation: "assigned_todo_liveness_dispatch",
|
||||
}, "normal_model"),
|
||||
requestedByActorType: "system",
|
||||
requestedByActorId: null,
|
||||
contextSnapshot: withRecoveryModelProfileHint({
|
||||
contextSnapshot: withRecoveryContext({
|
||||
issueId: issue.id,
|
||||
taskId: issue.id,
|
||||
wakeReason: "issue_assigned",
|
||||
|
|
@ -1187,13 +1184,13 @@ export function recoveryService(db: Db, deps: { enqueueWakeup: RecoveryWakeup })
|
|||
source: "automation",
|
||||
triggerDetail: "system",
|
||||
reason: "issue_assigned",
|
||||
payload: withRecoveryModelProfileHint({
|
||||
payload: withRecoveryContext({
|
||||
issueId: candidate.id,
|
||||
mutation: "unassigned_blocker_recovery",
|
||||
}, "normal_model"),
|
||||
requestedByActorType: "system",
|
||||
requestedByActorId: null,
|
||||
contextSnapshot: withRecoveryModelProfileHint({
|
||||
contextSnapshot: withRecoveryContext({
|
||||
issueId: candidate.id,
|
||||
taskId: candidate.id,
|
||||
wakeReason: "issue_assigned",
|
||||
|
|
@ -2150,7 +2147,7 @@ export function recoveryService(db: Db, deps: { enqueueWakeup: RecoveryWakeup })
|
|||
source: "automation",
|
||||
triggerDetail: "system",
|
||||
reason: "provider_quota_recovery",
|
||||
payload: withRecoveryModelProfileHint({
|
||||
payload: withRecoveryContext({
|
||||
issueId: input.issue.id,
|
||||
retryOfRunId: input.latestRun?.id ?? null,
|
||||
retryReason: "provider_quota_recovery",
|
||||
|
|
@ -2177,7 +2174,7 @@ export function recoveryService(db: Db, deps: { enqueueWakeup: RecoveryWakeup })
|
|||
scheduledRetryAt: retryAt,
|
||||
scheduledRetryAttempt: 1,
|
||||
scheduledRetryReason: "provider_quota_recovery",
|
||||
contextSnapshot: withRecoveryModelProfileHint({
|
||||
contextSnapshot: withRecoveryContext({
|
||||
issueId: input.issue.id,
|
||||
taskId: input.issue.id,
|
||||
wakeReason: "provider_quota_recovery",
|
||||
|
|
@ -2565,7 +2562,7 @@ export function recoveryService(db: Db, deps: { enqueueWakeup: RecoveryWakeup })
|
|||
const now = new Date();
|
||||
const retryAt = new Date(now.getTime() + timing.delayMs);
|
||||
const idempotencyKey = `issue_disposition_repair:${input.issue.id}:${input.fingerprint}:${input.attempt}`;
|
||||
const context = withRecoveryModelProfileHint({
|
||||
const context = withRecoveryContext({
|
||||
issueId: input.issue.id,
|
||||
taskId: input.issue.id,
|
||||
wakeReason: ISSUE_DISPOSITION_REPAIR_RETRY_REASON,
|
||||
|
|
@ -2603,7 +2600,7 @@ export function recoveryService(db: Db, deps: { enqueueWakeup: RecoveryWakeup })
|
|||
triggerDetail: "system",
|
||||
reason: ISSUE_DISPOSITION_REPAIR_RETRY_REASON,
|
||||
idempotencyKey,
|
||||
payload: withRecoveryModelProfileHint({
|
||||
payload: withRecoveryContext({
|
||||
issueId: input.issue.id,
|
||||
retryOfRunId: input.latestRun?.id ?? null,
|
||||
recoveryActionId: input.action.id,
|
||||
|
|
@ -2627,7 +2624,7 @@ export function recoveryService(db: Db, deps: { enqueueWakeup: RecoveryWakeup })
|
|||
source: "automation",
|
||||
triggerDetail: "system",
|
||||
reason: ISSUE_DISPOSITION_REPAIR_RETRY_REASON,
|
||||
payload: withRecoveryModelProfileHint({
|
||||
payload: withRecoveryContext({
|
||||
issueId: input.issue.id,
|
||||
retryOfRunId: input.latestRun?.id ?? null,
|
||||
recoveryActionId: input.action.id,
|
||||
|
|
|
|||
|
|
@ -0,0 +1,24 @@
|
|||
import { describe, expect, it } from "vitest";
|
||||
import { withRecoveryContext } from "./status-only-context.js";
|
||||
|
||||
describe("withRecoveryContext", () => {
|
||||
it("applies status-only mutation guards without selecting a model", () => {
|
||||
expect(withRecoveryContext({ issueId: "issue-1" }, "status_only")).toEqual({
|
||||
issueId: "issue-1",
|
||||
recoveryIntent: "status_only",
|
||||
allowDeliverableWork: false,
|
||||
allowDocumentUpdates: false,
|
||||
resumeRequiresNormalModel: true,
|
||||
});
|
||||
});
|
||||
|
||||
it("removes legacy model hints from all recovery work", () => {
|
||||
expect(withRecoveryContext({
|
||||
issueId: "issue-1",
|
||||
modelProfile: "cheap",
|
||||
paperclipModelProfile: { requested: "cheap" },
|
||||
}, "normal_model")).toEqual({
|
||||
issueId: "issue-1",
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
@ -0,0 +1,48 @@
|
|||
export type RecoveryWorkClass = "status_only" | "normal_model";
|
||||
|
||||
export const STATUS_ONLY_RECOVERY_GUARD_CONTEXT = {
|
||||
recoveryIntent: "status_only",
|
||||
allowDeliverableWork: false,
|
||||
allowDocumentUpdates: false,
|
||||
resumeRequiresNormalModel: true,
|
||||
} as const;
|
||||
|
||||
const RECOVERY_CONTEXT_KEYS = [
|
||||
// Retired model-profile fields are scrubbed from old queued contexts so an
|
||||
// upgrade cannot restore the removed execution path.
|
||||
"modelProfile",
|
||||
"paperclipModelProfile",
|
||||
"recoveryIntent",
|
||||
"allowDeliverableWork",
|
||||
"allowDocumentUpdates",
|
||||
"resumeRequiresNormalModel",
|
||||
] as const;
|
||||
|
||||
type RecoveryContextKey = (typeof RECOVERY_CONTEXT_KEYS)[number];
|
||||
type WithoutRecoveryContext<T> = Omit<T, RecoveryContextKey>;
|
||||
|
||||
export function scrubRecoveryContext<T extends Record<string, unknown>>(
|
||||
input: T,
|
||||
): WithoutRecoveryContext<T> {
|
||||
const output: Record<string, unknown> = { ...input };
|
||||
for (const key of RECOVERY_CONTEXT_KEYS) delete output[key];
|
||||
return output as WithoutRecoveryContext<T>;
|
||||
}
|
||||
|
||||
export function withRecoveryContext<T extends Record<string, unknown>>(
|
||||
input: T,
|
||||
workClass: "normal_model",
|
||||
): WithoutRecoveryContext<T>;
|
||||
export function withRecoveryContext<T extends Record<string, unknown>>(
|
||||
input: T,
|
||||
workClass: "status_only",
|
||||
): WithoutRecoveryContext<T> & typeof STATUS_ONLY_RECOVERY_GUARD_CONTEXT;
|
||||
export function withRecoveryContext<T extends Record<string, unknown>>(
|
||||
input: T,
|
||||
workClass: RecoveryWorkClass,
|
||||
): WithoutRecoveryContext<T> | (WithoutRecoveryContext<T> & typeof STATUS_ONLY_RECOVERY_GUARD_CONTEXT) {
|
||||
const scrubbed = scrubRecoveryContext(input);
|
||||
return workClass === "status_only"
|
||||
? { ...scrubbed, ...STATUS_ONLY_RECOVERY_GUARD_CONTEXT }
|
||||
: scrubbed;
|
||||
}
|
||||
|
|
@ -2,7 +2,7 @@ import { and, eq, inArray } from "drizzle-orm";
|
|||
import type { Db } from "@paperclipai/db";
|
||||
import { agentWakeupRequests, agents, heartbeatRuns, issues } from "@paperclipai/db";
|
||||
import type { IssueCommentMetadata, IssueCommentPresentation, RunLivenessState } from "@paperclipai/shared";
|
||||
import { withRecoveryModelProfileHint } from "./model-profile-hint.js";
|
||||
import { withRecoveryContext } from "./status-only-context.js";
|
||||
import {
|
||||
agentLinkRow,
|
||||
issueLinkRow,
|
||||
|
|
@ -512,7 +512,7 @@ export function decideSuccessfulRunHandoff(input: {
|
|||
nextAction: input.nextAction,
|
||||
detectedProgressSummary: input.detectedProgressSummary,
|
||||
});
|
||||
const payload = withRecoveryModelProfileHint({
|
||||
const payload = withRecoveryContext({
|
||||
issueId: issue.id,
|
||||
taskId: issue.id,
|
||||
sourceIssueId: issue.id,
|
||||
|
|
@ -540,7 +540,7 @@ export function decideSuccessfulRunHandoff(input: {
|
|||
}),
|
||||
payload,
|
||||
instruction,
|
||||
contextSnapshot: withRecoveryModelProfileHint({
|
||||
contextSnapshot: withRecoveryContext({
|
||||
...payload,
|
||||
wakeReason: FINISH_SUCCESSFUL_RUN_HANDOFF_REASON,
|
||||
livenessState: input.livenessState,
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@ const ALL_FALSE: AdapterCapabilities = {
|
|||
supportsSkills: false,
|
||||
supportsLocalAgentJwt: false,
|
||||
requiresMaterializedRuntimeSkills: false,
|
||||
supportsModelProfiles: false,
|
||||
supportsAcp: false,
|
||||
};
|
||||
|
||||
|
|
@ -21,15 +20,15 @@ const ALL_FALSE: AdapterCapabilities = {
|
|||
* Reconcile the two together if any adapter's login flow changes.
|
||||
*/
|
||||
const KNOWN_DEFAULTS: Record<string, AdapterCapabilities> = {
|
||||
claude_local: { supportsInstructionsBundle: true, supportsSkills: true, supportsLocalAgentJwt: true, requiresMaterializedRuntimeSkills: false, supportsModelProfiles: true, supportsAcp: true, login: { panelMode: "submitted_browser_code", timeoutPolicy: "fixed" } },
|
||||
codex_local: { supportsInstructionsBundle: true, supportsSkills: true, supportsLocalAgentJwt: true, requiresMaterializedRuntimeSkills: false, supportsModelProfiles: true, supportsAcp: true, login: { panelMode: "displayed_code", timeoutPolicy: "caller_bounded" } },
|
||||
paperclip_runner: { supportsInstructionsBundle: false, supportsSkills: true, supportsLocalAgentJwt: false, requiresMaterializedRuntimeSkills: false, supportsModelProfiles: false, supportsAcp: false },
|
||||
cursor: { supportsInstructionsBundle: true, supportsSkills: true, supportsLocalAgentJwt: true, requiresMaterializedRuntimeSkills: true, supportsModelProfiles: true, supportsAcp: false },
|
||||
gemini_local: { supportsInstructionsBundle: true, supportsSkills: true, supportsLocalAgentJwt: true, requiresMaterializedRuntimeSkills: true, supportsModelProfiles: true, supportsAcp: true },
|
||||
grok_local: { supportsInstructionsBundle: true, supportsSkills: true, supportsLocalAgentJwt: true, requiresMaterializedRuntimeSkills: true, supportsModelProfiles: false, supportsAcp: false, login: { panelMode: "displayed_code", timeoutPolicy: "caller_bounded" } },
|
||||
kimi_local: { supportsInstructionsBundle: true, supportsSkills: true, supportsLocalAgentJwt: true, requiresMaterializedRuntimeSkills: true, supportsModelProfiles: false, supportsAcp: true },
|
||||
opencode_local: { supportsInstructionsBundle: true, supportsSkills: true, supportsLocalAgentJwt: true, requiresMaterializedRuntimeSkills: true, supportsModelProfiles: true, supportsAcp: false },
|
||||
pi_local: { supportsInstructionsBundle: true, supportsSkills: true, supportsLocalAgentJwt: true, requiresMaterializedRuntimeSkills: true, supportsModelProfiles: false, supportsAcp: false },
|
||||
claude_local: { supportsInstructionsBundle: true, supportsSkills: true, supportsLocalAgentJwt: true, requiresMaterializedRuntimeSkills: false, supportsAcp: true, login: { panelMode: "submitted_browser_code", timeoutPolicy: "fixed" } },
|
||||
codex_local: { supportsInstructionsBundle: true, supportsSkills: true, supportsLocalAgentJwt: true, requiresMaterializedRuntimeSkills: false, supportsAcp: true, login: { panelMode: "displayed_code", timeoutPolicy: "caller_bounded" } },
|
||||
paperclip_runner: { supportsInstructionsBundle: false, supportsSkills: true, supportsLocalAgentJwt: false, requiresMaterializedRuntimeSkills: false, supportsAcp: false },
|
||||
cursor: { supportsInstructionsBundle: true, supportsSkills: true, supportsLocalAgentJwt: true, requiresMaterializedRuntimeSkills: true, supportsAcp: false },
|
||||
gemini_local: { supportsInstructionsBundle: true, supportsSkills: true, supportsLocalAgentJwt: true, requiresMaterializedRuntimeSkills: true, supportsAcp: true },
|
||||
grok_local: { supportsInstructionsBundle: true, supportsSkills: true, supportsLocalAgentJwt: true, requiresMaterializedRuntimeSkills: true, supportsAcp: false, login: { panelMode: "displayed_code", timeoutPolicy: "caller_bounded" } },
|
||||
kimi_local: { supportsInstructionsBundle: true, supportsSkills: true, supportsLocalAgentJwt: true, requiresMaterializedRuntimeSkills: true, supportsAcp: true },
|
||||
opencode_local: { supportsInstructionsBundle: true, supportsSkills: true, supportsLocalAgentJwt: true, requiresMaterializedRuntimeSkills: true, supportsAcp: false },
|
||||
pi_local: { supportsInstructionsBundle: true, supportsSkills: true, supportsLocalAgentJwt: true, requiresMaterializedRuntimeSkills: true, supportsAcp: false },
|
||||
openclaw_gateway: ALL_FALSE,
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@ export interface AdapterCapabilities {
|
|||
supportsSkills: boolean;
|
||||
supportsLocalAgentJwt: boolean;
|
||||
requiresMaterializedRuntimeSkills: boolean;
|
||||
supportsModelProfiles: boolean;
|
||||
supportsAcp: boolean;
|
||||
/** Present only when the adapter declares an interactive login capability. */
|
||||
login?: AdapterLoginProjection;
|
||||
|
|
|
|||
|
|
@ -28,10 +28,6 @@ import type {
|
|||
ClearAgentErrorResponse,
|
||||
AgentApiKeyScope,
|
||||
} from "@paperclipai/shared";
|
||||
import type {
|
||||
AdapterModelProfileDefinition,
|
||||
AdapterModelProfileKey,
|
||||
} from "@paperclipai/adapter-utils";
|
||||
import { isUuidLike, normalizeAgentUrlKey } from "@paperclipai/shared";
|
||||
import { ApiError, api } from "./client";
|
||||
|
||||
|
|
@ -48,9 +44,6 @@ export interface AdapterModel {
|
|||
label: string;
|
||||
}
|
||||
|
||||
export type { AdapterModelProfileKey };
|
||||
export type AdapterModelProfile = AdapterModelProfileDefinition;
|
||||
|
||||
export interface DetectedAdapterModel {
|
||||
model: string;
|
||||
provider: string;
|
||||
|
|
@ -223,10 +216,6 @@ export const agentsApi = {
|
|||
api.get<DetectedAdapterModel | null>(
|
||||
`/companies/${encodeURIComponent(companyId)}/adapters/${encodeURIComponent(type)}/detect-model`,
|
||||
),
|
||||
adapterModelProfiles: (companyId: string, type: string) =>
|
||||
api.get<AdapterModelProfile[]>(
|
||||
`/companies/${encodeURIComponent(companyId)}/adapters/${encodeURIComponent(type)}/model-profiles`,
|
||||
),
|
||||
testEnvironment: (
|
||||
companyId: string,
|
||||
type: string,
|
||||
|
|
|
|||
|
|
@ -15,7 +15,6 @@ import { buildNewAgentHirePayload } from "../lib/new-agent-hire-payload";
|
|||
import { ApiError } from "../api/client";
|
||||
|
||||
const mockAgentsApi = vi.hoisted(() => ({
|
||||
adapterModelProfiles: vi.fn(),
|
||||
adapterModels: vi.fn(),
|
||||
detectModel: vi.fn(),
|
||||
list: vi.fn(),
|
||||
|
|
@ -143,7 +142,6 @@ vi.mock("../adapters/use-adapter-capabilities", () => ({
|
|||
supportsSkills: false,
|
||||
supportsLocalAgentJwt: false,
|
||||
requiresMaterializedRuntimeSkills: false,
|
||||
supportsModelProfiles: false,
|
||||
supportsAcp: false,
|
||||
}
|
||||
: {
|
||||
|
|
@ -151,7 +149,6 @@ vi.mock("../adapters/use-adapter-capabilities", () => ({
|
|||
supportsSkills: true,
|
||||
supportsLocalAgentJwt: true,
|
||||
requiresMaterializedRuntimeSkills: false,
|
||||
supportsModelProfiles: true,
|
||||
supportsAcp: true,
|
||||
...(login ? { login } : {}),
|
||||
};
|
||||
|
|
@ -632,7 +629,6 @@ describe("AgentConfigForm environment selector", () => {
|
|||
let roots: Root[] = [];
|
||||
|
||||
beforeEach(() => {
|
||||
mockAgentsApi.adapterModelProfiles.mockResolvedValue([]);
|
||||
mockAgentsApi.adapterModels.mockResolvedValue([]);
|
||||
mockAgentsApi.detectModel.mockResolvedValue(null);
|
||||
mockAgentsApi.list.mockResolvedValue([]);
|
||||
|
|
@ -879,51 +875,6 @@ describe("AgentConfigForm environment selector", () => {
|
|||
expect(result.container.textContent).toContain("Hermes Gateway fields");
|
||||
});
|
||||
|
||||
it("tests both the primary and cheap models when a cheap profile is configured", async () => {
|
||||
const result = await renderForm([
|
||||
makeEnvironment({ id: "local-1", name: "Local", driver: "local" }),
|
||||
], {
|
||||
adapterConfig: { model: "gpt-5.4" },
|
||||
runtimeConfig: {
|
||||
modelProfiles: {
|
||||
cheap: {
|
||||
enabled: true,
|
||||
adapterConfig: {
|
||||
model: "gpt-5.4-mini",
|
||||
baseUrl: "https://cheap-models.example.test",
|
||||
provider: "budget-provider",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}, {
|
||||
showAdapterTestEnvironmentButton: true,
|
||||
});
|
||||
roots.push(result.root);
|
||||
|
||||
const testButton = Array.from(result.container.querySelectorAll("button")).find(
|
||||
(button) => button.textContent?.trim() === "Test",
|
||||
);
|
||||
expect(testButton).toBeTruthy();
|
||||
|
||||
await act(async () => {
|
||||
testButton?.dispatchEvent(new MouseEvent("click", { bubbles: true }));
|
||||
});
|
||||
await flushReact();
|
||||
|
||||
expect(mockAgentsApi.testEnvironment).toHaveBeenCalledTimes(2);
|
||||
expect(mockAgentsApi.testEnvironment.mock.calls[0]?.[2]).toMatchObject({
|
||||
adapterConfig: expect.objectContaining({ model: "gpt-5.4" }),
|
||||
});
|
||||
expect(mockAgentsApi.testEnvironment.mock.calls[1]?.[2]).toMatchObject({
|
||||
adapterConfig: expect.objectContaining({
|
||||
model: "gpt-5.4-mini",
|
||||
baseUrl: "https://cheap-models.example.test",
|
||||
provider: "budget-provider",
|
||||
}),
|
||||
});
|
||||
});
|
||||
|
||||
it("tests a Codex agent after clearing the primary model to the adapter default", async () => {
|
||||
const result = await renderForm([
|
||||
makeEnvironment({ id: "local-1", name: "Local", driver: "local" }),
|
||||
|
|
@ -1057,14 +1008,6 @@ describe("AgentConfigForm environment selector", () => {
|
|||
makeEnvironment({ id: "local-1", name: "Local", driver: "local" }),
|
||||
], {
|
||||
adapterConfig: { model: "gpt-5.4" },
|
||||
runtimeConfig: {
|
||||
modelProfiles: {
|
||||
cheap: {
|
||||
enabled: true,
|
||||
adapterConfig: { model: "gpt-5.4-mini" },
|
||||
},
|
||||
},
|
||||
},
|
||||
}, {
|
||||
showAdapterTestEnvironmentButton: true,
|
||||
});
|
||||
|
|
@ -2465,7 +2408,6 @@ describe("AgentConfigForm create-mode Claude OAuth binding", () => {
|
|||
let roots: Root[] = [];
|
||||
|
||||
beforeEach(() => {
|
||||
mockAgentsApi.adapterModelProfiles.mockResolvedValue([]);
|
||||
mockAgentsApi.adapterModels.mockResolvedValue([]);
|
||||
mockAgentsApi.detectModel.mockResolvedValue(null);
|
||||
mockAgentsApi.list.mockResolvedValue([]);
|
||||
|
|
@ -2664,7 +2606,6 @@ describe("AgentConfigForm edit-mode Claude OAuth binding", () => {
|
|||
let roots: Root[] = [];
|
||||
|
||||
beforeEach(() => {
|
||||
mockAgentsApi.adapterModelProfiles.mockResolvedValue([]);
|
||||
mockAgentsApi.adapterModels.mockResolvedValue([]);
|
||||
mockAgentsApi.detectModel.mockResolvedValue(null);
|
||||
mockAgentsApi.list.mockResolvedValue([]);
|
||||
|
|
@ -2789,7 +2730,6 @@ describe("AgentConfigForm managed-sandbox-only host surfaces", () => {
|
|||
}
|
||||
|
||||
beforeEach(() => {
|
||||
mockAgentsApi.adapterModelProfiles.mockResolvedValue([]);
|
||||
mockAgentsApi.adapterModels.mockResolvedValue([]);
|
||||
mockAgentsApi.detectModel.mockResolvedValue(null);
|
||||
mockAgentsApi.list.mockResolvedValue([]);
|
||||
|
|
|
|||
|
|
@ -51,7 +51,6 @@ import {
|
|||
help,
|
||||
adapterLabels,
|
||||
} from "./agent-config-primitives";
|
||||
import { ToggleSwitch } from "@/components/ui/toggle-switch";
|
||||
import { defaultCreateValues } from "./agent-config-defaults";
|
||||
import { getUIAdapter } from "../adapters";
|
||||
import { ClaudeLocalAdvancedFields } from "../adapters/claude-local/config-fields";
|
||||
|
|
@ -153,8 +152,7 @@ function isOverlayDirty(o: AgentConfigOverlay): boolean {
|
|||
Object.keys(o.adapterConfig).length > 0 ||
|
||||
Object.keys(o.heartbeat).length > 0 ||
|
||||
Object.keys(o.debug).length > 0 ||
|
||||
Object.keys(o.runtime).length > 0 ||
|
||||
o.modelProfiles?.cheap !== undefined
|
||||
Object.keys(o.runtime).length > 0
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -778,30 +776,8 @@ export function AgentConfigForm(props: AgentConfigFormProps) {
|
|||
const [runPolicyAdvancedOpen, setRunPolicyAdvancedOpen] = useState(false);
|
||||
// Popover states
|
||||
const [modelOpen, setModelOpen] = useState(false);
|
||||
const [cheapModelOpen, setCheapModelOpen] = useState(false);
|
||||
const [thinkingEffortOpen, setThinkingEffortOpen] = useState(false);
|
||||
|
||||
// Cheap model profile state — only relevant when the adapter advertises
|
||||
// `supportsModelProfiles`. Defaults are sourced from the adapter's
|
||||
// /model-profiles endpoint so the UI does not encode adapter-specific
|
||||
// cheap defaults.
|
||||
const supportsModelProfiles = adapterCaps.supportsModelProfiles;
|
||||
const { data: adapterCheapProfileDefinitions } = useQuery({
|
||||
queryKey: selectedCompanyId
|
||||
? queryKeys.agents.adapterModelProfiles(selectedCompanyId, adapterType)
|
||||
: ["agents", "none", "adapter-model-profiles", adapterType],
|
||||
queryFn: () => agentsApi.adapterModelProfiles(selectedCompanyId!, adapterType),
|
||||
enabled: Boolean(selectedCompanyId) && supportsModelProfiles,
|
||||
});
|
||||
const adapterCheapDefault = useMemo(() => {
|
||||
return (adapterCheapProfileDefinitions ?? []).find((profile) => profile.key === "cheap") ?? null;
|
||||
}, [adapterCheapProfileDefinitions]);
|
||||
const adapterCheapDefaultModel = useMemo(() => {
|
||||
const adapterConfig = adapterCheapDefault?.adapterConfig ?? {};
|
||||
const value = (adapterConfig as Record<string, unknown>).model;
|
||||
return typeof value === "string" ? value : "";
|
||||
}, [adapterCheapDefault]);
|
||||
|
||||
function buildAdapterConfigForTest(adapterConfigPatch?: Record<string, unknown>): Record<string, unknown> {
|
||||
if (isCreate) {
|
||||
const next = uiAdapter.buildAdapterConfig(val!);
|
||||
|
|
@ -818,86 +794,6 @@ export function AgentConfigForm(props: AgentConfigFormProps) {
|
|||
return omitUndefinedEntries(next);
|
||||
}
|
||||
|
||||
function buildCheapAdapterConfigForTest(adapterConfigPatch?: Record<string, unknown>): Record<string, unknown> {
|
||||
const adapterDefaultConfig = asObject(adapterCheapDefault?.adapterConfig);
|
||||
const createCheapModel = isCreate ? (val!.cheapModel ?? "").trim() : "";
|
||||
const cheapAdapterConfig = isCreate
|
||||
? {
|
||||
...adapterDefaultConfig,
|
||||
...(createCheapModel ? { model: createCheapModel } : {}),
|
||||
}
|
||||
: {
|
||||
...adapterDefaultConfig,
|
||||
...cheapProfileFromAgent.adapterConfig,
|
||||
...asObject(cheapOverlay?.adapterConfig),
|
||||
};
|
||||
return buildAdapterConfigForTest({ ...cheapAdapterConfig, ...adapterConfigPatch });
|
||||
}
|
||||
|
||||
function getCheapModelTestCase(adapterConfigPatch?: Record<string, unknown>): { model: string; adapterConfig: Record<string, unknown> } | null {
|
||||
if (!currentCheapEnabled) return null;
|
||||
const adapterConfig = buildCheapAdapterConfigForTest(adapterConfigPatch);
|
||||
const configModel = typeof adapterConfig.model === "string" ? adapterConfig.model.trim() : "";
|
||||
const model = configModel || currentCheapModel.trim();
|
||||
if (!model) return null;
|
||||
adapterConfig.model = model;
|
||||
return { model, adapterConfig };
|
||||
}
|
||||
|
||||
function prefixEnvironmentTestChecks(
|
||||
result: AdapterEnvironmentTestResult,
|
||||
label: string,
|
||||
model: string | null,
|
||||
): AdapterEnvironmentTestResult {
|
||||
const modelLabel = model ? ` (${model})` : "";
|
||||
return {
|
||||
...result,
|
||||
checks: [
|
||||
{
|
||||
code: `${label.toLowerCase().replace(/[^a-z0-9]+/g, "_")}_test_started`,
|
||||
level: "info",
|
||||
message: `${label} test${modelLabel}`,
|
||||
},
|
||||
...result.checks.map((check) => ({
|
||||
...check,
|
||||
message: `${label} test${modelLabel}: ${check.message}`,
|
||||
})),
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
async function runEnvironmentTestCase(
|
||||
label: string,
|
||||
model: string | null,
|
||||
adapterConfig: Record<string, unknown>,
|
||||
environmentId: string | null,
|
||||
): Promise<AdapterEnvironmentTestResult> {
|
||||
const result = await agentsApi.testEnvironment(selectedCompanyId!, adapterType, {
|
||||
adapterConfig,
|
||||
environmentId,
|
||||
});
|
||||
return prefixEnvironmentTestChecks(result, label, model);
|
||||
}
|
||||
|
||||
function mergeEnvironmentTestResults(
|
||||
results: AdapterEnvironmentTestResult[],
|
||||
): AdapterEnvironmentTestResult {
|
||||
const checks = results.flatMap((result) => result.checks);
|
||||
const status = results.some((result) => result.status === "fail")
|
||||
? "fail"
|
||||
: results.some((result) => result.status === "warn")
|
||||
? "warn"
|
||||
: "pass";
|
||||
const testedAt = results[results.length - 1]?.testedAt ?? new Date().toISOString();
|
||||
|
||||
return {
|
||||
adapterType,
|
||||
status,
|
||||
checks,
|
||||
testedAt,
|
||||
};
|
||||
}
|
||||
|
||||
const testEnvironment = useMutation({
|
||||
mutationFn: async () => {
|
||||
if (!selectedCompanyId) {
|
||||
|
|
@ -905,8 +801,6 @@ export function AgentConfigForm(props: AgentConfigFormProps) {
|
|||
}
|
||||
const flushedEnv = flushEnvironmentDraft();
|
||||
const adapterConfigPatch = flushedEnv ? { env: flushedEnv } : undefined;
|
||||
const primaryModel = currentModelId.trim() || null;
|
||||
const cheapTestCase = getCheapModelTestCase(adapterConfigPatch);
|
||||
// Probe where a real run would actually execute: the agent's own
|
||||
// environment, else the instance default. Testing the host for an
|
||||
// agent that runs in the instance-default sandbox reports failures
|
||||
|
|
@ -974,35 +868,10 @@ export function AgentConfigForm(props: AgentConfigFormProps) {
|
|||
// managed sandbox instead of sending the hidden local id to the server.
|
||||
visibleEnvironmentIds: environmentList.map((environment) => environment.id),
|
||||
});
|
||||
const testResults: Array<{ label: string; model: string | null; result: AdapterEnvironmentTestResult }> = [
|
||||
{
|
||||
label: "Primary model",
|
||||
model: primaryModel,
|
||||
result: await runEnvironmentTestCase(
|
||||
"Primary model",
|
||||
primaryModel,
|
||||
buildAdapterConfigForTest(adapterConfigPatch),
|
||||
environmentId,
|
||||
),
|
||||
},
|
||||
];
|
||||
|
||||
if (cheapTestCase) {
|
||||
testResults.push({
|
||||
label: "Cheap model",
|
||||
model: cheapTestCase.model,
|
||||
result: await runEnvironmentTestCase(
|
||||
"Cheap model",
|
||||
cheapTestCase.model,
|
||||
cheapTestCase.adapterConfig,
|
||||
environmentId,
|
||||
),
|
||||
});
|
||||
}
|
||||
|
||||
return testResults.length > 1
|
||||
? mergeEnvironmentTestResults(testResults.map(({ result }) => result))
|
||||
: testResults[0]!.result;
|
||||
return agentsApi.testEnvironment(selectedCompanyId, adapterType, {
|
||||
adapterConfig: buildAdapterConfigForTest(adapterConfigPatch),
|
||||
environmentId,
|
||||
});
|
||||
},
|
||||
});
|
||||
const [testActionPending, setTestActionPending] = useState(false);
|
||||
|
|
@ -1228,70 +1097,6 @@ export function AgentConfigForm(props: AgentConfigFormProps) {
|
|||
const codexSearchEnabled = adapterType === "codex_local"
|
||||
? (isCreate ? Boolean(val!.search) : eff("adapterConfig", "search", Boolean(config.search)))
|
||||
: false;
|
||||
// Cheap profile read/write helpers. Edit-mode values come from
|
||||
// runtimeConfig.modelProfiles.cheap with overlay overrides on top; create-mode
|
||||
// values come straight from CreateConfigValues (cheapModel + cheapModelEnabled).
|
||||
const cheapProfileFromAgent = useMemo(() => {
|
||||
const profiles = (runtimeConfig.modelProfiles ?? {}) as Record<string, unknown>;
|
||||
const cheap = (profiles.cheap ?? {}) as Record<string, unknown>;
|
||||
const cheapAdapterConfig = asObject(cheap.adapterConfig);
|
||||
return {
|
||||
enabled: cheap.enabled !== false,
|
||||
adapterConfig: cheapAdapterConfig,
|
||||
model: typeof cheapAdapterConfig.model === "string" ? cheapAdapterConfig.model : "",
|
||||
};
|
||||
}, [runtimeConfig]);
|
||||
const cheapOverlay = !isCreate ? overlay.modelProfiles?.cheap : undefined;
|
||||
const currentCheapEnabled = isCreate
|
||||
? val!.cheapModelEnabled ?? false
|
||||
: cheapOverlay?.enabled ?? cheapProfileFromAgent.enabled;
|
||||
const currentCheapModel = isCreate
|
||||
? val!.cheapModel ?? ""
|
||||
: (() => {
|
||||
const overlayModel = (cheapOverlay?.adapterConfig as Record<string, unknown> | undefined)?.model;
|
||||
if (typeof overlayModel === "string") return overlayModel;
|
||||
return cheapProfileFromAgent.model;
|
||||
})();
|
||||
|
||||
function setCheapEnabled(next: boolean) {
|
||||
if (isCreate) {
|
||||
set!({ cheapModelEnabled: next });
|
||||
return;
|
||||
}
|
||||
setOverlay((prev) => ({
|
||||
...prev,
|
||||
modelProfiles: {
|
||||
cheap: {
|
||||
...(prev.modelProfiles?.cheap ?? {}),
|
||||
enabled: next,
|
||||
},
|
||||
},
|
||||
}));
|
||||
}
|
||||
|
||||
function setCheapModel(next: string) {
|
||||
if (isCreate) {
|
||||
set!({ cheapModel: next });
|
||||
return;
|
||||
}
|
||||
setOverlay((prev) => {
|
||||
const existing = prev.modelProfiles?.cheap ?? {};
|
||||
const nextAdapterConfig = {
|
||||
...((existing.adapterConfig ?? {}) as Record<string, unknown>),
|
||||
model: next || undefined,
|
||||
};
|
||||
return {
|
||||
...prev,
|
||||
modelProfiles: {
|
||||
cheap: {
|
||||
...existing,
|
||||
adapterConfig: nextAdapterConfig,
|
||||
},
|
||||
},
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
const effectiveRuntimeConfig = useMemo(() => {
|
||||
if (isCreate) {
|
||||
return {
|
||||
|
|
@ -1579,7 +1384,6 @@ export function AgentConfigForm(props: AgentConfigFormProps) {
|
|||
setOverlay((prev) => ({
|
||||
...prev,
|
||||
adapterType: t,
|
||||
modelProfiles: { cheap: { cleared: true } },
|
||||
adapterConfig: {
|
||||
model:
|
||||
t === "gemini_local"
|
||||
|
|
@ -1722,9 +1526,6 @@ export function AgentConfigForm(props: AgentConfigFormProps) {
|
|||
</Field>
|
||||
)}
|
||||
|
||||
{supportsModelProfiles && (
|
||||
<div className="text-(length:--text-micro) uppercase tracking-wide text-muted-foreground">Primary model</div>
|
||||
)}
|
||||
<ModelDropdown
|
||||
models={models}
|
||||
value={currentModelId}
|
||||
|
|
@ -1772,20 +1573,6 @@ export function AgentConfigForm(props: AgentConfigFormProps) {
|
|||
</p>
|
||||
)}
|
||||
|
||||
{supportsModelProfiles && (
|
||||
<CheapModelSection
|
||||
enabled={currentCheapEnabled}
|
||||
model={currentCheapModel}
|
||||
models={models}
|
||||
adapterType={adapterType}
|
||||
adapterDefaultModel={adapterCheapDefaultModel}
|
||||
onEnabledChange={setCheapEnabled}
|
||||
onModelChange={setCheapModel}
|
||||
open={cheapModelOpen}
|
||||
onOpenChange={setCheapModelOpen}
|
||||
/>
|
||||
)}
|
||||
|
||||
{showThinkingEffort && (
|
||||
<>
|
||||
<ThinkingEffortDropdown
|
||||
|
|
@ -3360,72 +3147,6 @@ export function ModelDropdown({
|
|||
);
|
||||
}
|
||||
|
||||
function CheapModelSection({
|
||||
enabled,
|
||||
model,
|
||||
models,
|
||||
adapterType,
|
||||
adapterDefaultModel,
|
||||
onEnabledChange,
|
||||
onModelChange,
|
||||
open,
|
||||
onOpenChange,
|
||||
}: {
|
||||
enabled: boolean;
|
||||
model: string;
|
||||
models: AdapterModel[];
|
||||
adapterType: string;
|
||||
adapterDefaultModel: string;
|
||||
onEnabledChange: (next: boolean) => void;
|
||||
onModelChange: (next: string) => void;
|
||||
open: boolean;
|
||||
onOpenChange: (open: boolean) => void;
|
||||
}) {
|
||||
const placeholderHint = adapterDefaultModel
|
||||
? `Adapter default · ${adapterDefaultModel}`
|
||||
: "No adapter default — choose a cheaper model";
|
||||
return (
|
||||
<div className="rounded-md border border-border/70 bg-muted/20 p-3 space-y-3">
|
||||
<div className="flex items-center justify-between gap-3">
|
||||
<div className="min-w-0">
|
||||
<div className="text-(length:--text-micro) uppercase tracking-wide text-muted-foreground">Cheap model</div>
|
||||
<p className="text-xs text-muted-foreground">
|
||||
Used when a run requests the cheap profile (e.g. routine summaries). The primary model stays unchanged.
|
||||
</p>
|
||||
</div>
|
||||
<ToggleSwitch checked={enabled} onCheckedChange={onEnabledChange} />
|
||||
</div>
|
||||
{enabled ? (
|
||||
<ModelDropdown
|
||||
models={models}
|
||||
value={model}
|
||||
onChange={onModelChange}
|
||||
open={open}
|
||||
onOpenChange={onOpenChange}
|
||||
allowDefault
|
||||
required={false}
|
||||
groupByProvider={adapterType === "opencode_local"}
|
||||
creatable
|
||||
detectedModel={null}
|
||||
detectedModelCandidates={[]}
|
||||
emptyDetectHint={placeholderHint}
|
||||
defaultLabel={placeholderHint}
|
||||
/>
|
||||
) : null}
|
||||
{enabled && !model && adapterDefaultModel ? (
|
||||
<p className="text-(length:--text-micro) text-muted-foreground">
|
||||
No explicit cheap model selected — runtime falls back to <code>{adapterDefaultModel}</code>.
|
||||
</p>
|
||||
) : null}
|
||||
{enabled && !model && !adapterDefaultModel ? (
|
||||
<p className="text-(length:--text-micro) text-amber-500">
|
||||
No cheap model selected and the adapter has no default. Cheap-lane runs will continue on the primary model with a fallback note.
|
||||
</p>
|
||||
) : null}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function ThinkingEffortDropdown({
|
||||
value,
|
||||
options,
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@ import { queryKeys } from "../lib/queryKeys";
|
|||
const mockAgentsApi = vi.hoisted(() => ({
|
||||
list: vi.fn(),
|
||||
adapterModels: vi.fn(),
|
||||
adapterModelProfiles: vi.fn(),
|
||||
}));
|
||||
|
||||
const mockProjectsApi = vi.hoisted(() => ({
|
||||
|
|
@ -462,7 +461,6 @@ describe("IssueProperties", () => {
|
|||
document.body.appendChild(container);
|
||||
mockAgentsApi.list.mockResolvedValue([]);
|
||||
mockAgentsApi.adapterModels.mockResolvedValue([]);
|
||||
mockAgentsApi.adapterModelProfiles.mockResolvedValue([]);
|
||||
mockProjectsApi.list.mockResolvedValue([]);
|
||||
mockExecutionWorkspacesApi.controlRuntimeCommands.mockReset();
|
||||
mockIssuesApi.list.mockResolvedValue([]);
|
||||
|
|
|
|||
|
|
@ -530,41 +530,6 @@ describe("IssueRunLedger", () => {
|
|||
});
|
||||
});
|
||||
|
||||
it("renders requested/applied model profile and surfaces fallback reasons", () => {
|
||||
renderLedger({
|
||||
runs: [
|
||||
createRun({
|
||||
runId: "run-cheap-applied",
|
||||
resultJson: {
|
||||
modelProfile: {
|
||||
requested: "cheap",
|
||||
applied: "cheap",
|
||||
configSource: "agent_runtime",
|
||||
fallbackReason: null,
|
||||
},
|
||||
},
|
||||
}),
|
||||
createRun({
|
||||
runId: "run-cheap-fallback",
|
||||
createdAt: "2026-04-18T19:50:00.000Z",
|
||||
resultJson: {
|
||||
modelProfile: {
|
||||
requested: "cheap",
|
||||
applied: null,
|
||||
configSource: null,
|
||||
fallbackReason: "agent_runtime_profile_disabled",
|
||||
},
|
||||
},
|
||||
}),
|
||||
],
|
||||
});
|
||||
|
||||
expect(container.textContent).toContain("Profile: cheap");
|
||||
expect(container.textContent).toContain("Profile: cheap (unavailable)");
|
||||
expect(container.textContent).toContain("Cheap profile fell back to primary");
|
||||
expect(container.textContent).toContain("agent_runtime_profile_disabled");
|
||||
});
|
||||
|
||||
it("hides watchdog decision actions for known non-owner viewers", () => {
|
||||
const onWatchdogDecision = vi.fn();
|
||||
renderLedger({
|
||||
|
|
|
|||
|
|
@ -188,45 +188,6 @@ function readString(value: unknown) {
|
|||
: null;
|
||||
}
|
||||
|
||||
interface ModelProfileSummary {
|
||||
requested: string;
|
||||
applied: string | null;
|
||||
configSource: string | null;
|
||||
fallbackReason: string | null;
|
||||
}
|
||||
|
||||
function modelProfileForRun(run: RunForIssue): ModelProfileSummary | null {
|
||||
const result = asRecord(run.resultJson);
|
||||
const profile = asRecord(result?.modelProfile);
|
||||
if (!profile) return null;
|
||||
const requested = readString(profile.requested);
|
||||
if (!requested) return null;
|
||||
return {
|
||||
requested,
|
||||
applied: readString(profile.applied),
|
||||
configSource: readString(profile.configSource),
|
||||
fallbackReason: readString(profile.fallbackReason),
|
||||
};
|
||||
}
|
||||
|
||||
function modelProfileBadgeTone(summary: ModelProfileSummary) {
|
||||
if (summary.applied === summary.requested) {
|
||||
return "border-emerald-500/30 bg-emerald-500/10 text-emerald-700 dark:text-emerald-300";
|
||||
}
|
||||
if (summary.fallbackReason) {
|
||||
return "border-amber-500/30 bg-amber-500/10 text-amber-700 dark:text-amber-300";
|
||||
}
|
||||
return "border-border bg-background text-muted-foreground";
|
||||
}
|
||||
|
||||
function modelProfileTitle(summary: ModelProfileSummary) {
|
||||
const lines = [`Requested: ${summary.requested}`];
|
||||
if (summary.applied) lines.push(`Applied: ${summary.applied}`);
|
||||
if (summary.configSource) lines.push(`Source: ${summary.configSource}`);
|
||||
if (summary.fallbackReason) lines.push(`Fallback: ${summary.fallbackReason}`);
|
||||
return lines.join("\n");
|
||||
}
|
||||
|
||||
function readNumber(value: unknown) {
|
||||
return typeof value === "number" && Number.isFinite(value) ? value : null;
|
||||
}
|
||||
|
|
@ -975,27 +936,6 @@ export function IssueRunLedgerContent({
|
|||
{RUN_OUTPUT_SILENCE_COPY[run.outputSilence.level]?.label}
|
||||
</span>
|
||||
) : null}
|
||||
{(() => {
|
||||
const profile = modelProfileForRun(run);
|
||||
if (!profile) return null;
|
||||
const label =
|
||||
profile.applied === profile.requested
|
||||
? `Profile: ${profile.requested}`
|
||||
: profile.applied
|
||||
? `Profile: ${profile.requested} → ${profile.applied}`
|
||||
: `Profile: ${profile.requested} (unavailable)`;
|
||||
return (
|
||||
<span
|
||||
className={cn(
|
||||
"rounded-md border px-1.5 py-0.5 text-(length:--text-micro) font-medium",
|
||||
modelProfileBadgeTone(profile),
|
||||
)}
|
||||
title={modelProfileTitle(profile)}
|
||||
>
|
||||
{label}
|
||||
</span>
|
||||
);
|
||||
})()}
|
||||
{sourceResolvedFold ? <SourceResolvedFoldBadge /> : null}
|
||||
<span className="ml-auto shrink-0">
|
||||
{relativeTime(item.timestamp)}
|
||||
|
|
@ -1044,26 +984,6 @@ export function IssueRunLedgerContent({
|
|||
</div>
|
||||
) : null}
|
||||
|
||||
{(() => {
|
||||
const profile = modelProfileForRun(run);
|
||||
if (
|
||||
!profile?.fallbackReason ||
|
||||
profile.applied === profile.requested
|
||||
)
|
||||
return null;
|
||||
return (
|
||||
<p className="min-w-0 break-words text-(length:--text-micro) leading-5 text-amber-700 dark:text-amber-300">
|
||||
{profile.requested === "cheap"
|
||||
? "Cheap profile fell back to primary"
|
||||
: `${profile.requested} profile unavailable`}
|
||||
{": "}
|
||||
<span className="font-mono">
|
||||
{profile.fallbackReason}
|
||||
</span>
|
||||
</p>
|
||||
);
|
||||
})()}
|
||||
|
||||
{run.livenessReason ? (
|
||||
<p className="min-w-0 break-words text-xs leading-5 text-muted-foreground">
|
||||
{run.livenessReason}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ import { useQuery, useMutation, useQueryClient } from "@tanstack/react-query";
|
|||
import type { AgentEnvConfig, EnvBinding, IssueWorkMode } from "@paperclipai/shared";
|
||||
import { useDialog } from "../context/DialogContext";
|
||||
import { useCompany } from "../context/CompanyContext";
|
||||
import { useAdapterCapabilities } from "../adapters/use-adapter-capabilities";
|
||||
import { executionWorkspacesApi } from "../api/execution-workspaces";
|
||||
import { issuesApi } from "../api/issues";
|
||||
import { MissingUserSecretsBanner } from "../pages/secrets/MissingUserSecretsBanner";
|
||||
|
|
@ -595,25 +594,6 @@ export function NewIssueDialog() {
|
|||
const supportsAssigneeOverrides = Boolean(
|
||||
assigneeAdapterType && ISSUE_OVERRIDE_ADAPTER_TYPES.has(assigneeAdapterType),
|
||||
);
|
||||
const getAdapterCapabilities = useAdapterCapabilities();
|
||||
const assigneeAdapterCapabilities = assigneeAdapterType
|
||||
? getAdapterCapabilities(assigneeAdapterType)
|
||||
: null;
|
||||
const assigneeSupportsCheapLane = Boolean(
|
||||
supportsAssigneeOverrides && assigneeAdapterCapabilities?.supportsModelProfiles,
|
||||
);
|
||||
|
||||
const { data: assigneeCheapProfiles } = useQuery({
|
||||
queryKey: effectiveCompanyId && assigneeAdapterType
|
||||
? queryKeys.agents.adapterModelProfiles(effectiveCompanyId, assigneeAdapterType)
|
||||
: ["agents", "none", "adapter-model-profiles", assigneeAdapterType ?? "none"],
|
||||
queryFn: () => agentsApi.adapterModelProfiles(effectiveCompanyId!, assigneeAdapterType!),
|
||||
enabled: Boolean(effectiveCompanyId) && newIssueOpen && assigneeSupportsCheapLane,
|
||||
});
|
||||
const assigneeCheapProfile = useMemo(
|
||||
() => (assigneeCheapProfiles ?? []).find((profile) => profile.key === "cheap") ?? null,
|
||||
[assigneeCheapProfiles],
|
||||
);
|
||||
const mentionOptions = useMemo<MentionOption[]>(() => {
|
||||
return buildMarkdownMentionOptions({
|
||||
agents,
|
||||
|
|
@ -952,10 +932,6 @@ export function NewIssueDialog() {
|
|||
setAssigneeChrome(false);
|
||||
return;
|
||||
}
|
||||
if (!assigneeSupportsCheapLane && assigneeModelLane === "cheap") {
|
||||
setAssigneeModelLane("primary");
|
||||
}
|
||||
|
||||
const validThinkingValues =
|
||||
assigneeAdapterType === "codex_local"
|
||||
? ISSUE_THINKING_EFFORT_OPTIONS.codex_local
|
||||
|
|
@ -969,8 +945,6 @@ export function NewIssueDialog() {
|
|||
supportsAssigneeOverrides,
|
||||
assigneeAdapterType,
|
||||
assigneeThinkingEffort,
|
||||
assigneeSupportsCheapLane,
|
||||
assigneeModelLane,
|
||||
]);
|
||||
|
||||
// Cleanup timer on unmount
|
||||
|
|
@ -1044,14 +1018,9 @@ export function NewIssueDialog() {
|
|||
const currentTitle = titleRef.current.trim();
|
||||
const currentDescription = descriptionRef.current.trim();
|
||||
if (!effectiveCompanyId || !currentTitle || createIssue.isPending) return;
|
||||
const effectiveLane = assigneeSupportsCheapLane
|
||||
? assigneeModelLane
|
||||
: assigneeModelLane === "cheap"
|
||||
? "primary"
|
||||
: assigneeModelLane;
|
||||
const assigneeAdapterOverrides = buildAssigneeAdapterOverrides({
|
||||
adapterType: assigneeAdapterType,
|
||||
lane: effectiveLane,
|
||||
lane: assigneeModelLane,
|
||||
modelOverride: assigneeModelOverride,
|
||||
thinkingEffortOverride: assigneeThinkingEffort,
|
||||
chrome: assigneeChrome,
|
||||
|
|
@ -1933,7 +1902,7 @@ export function NewIssueDialog() {
|
|||
role="radiogroup"
|
||||
aria-label="Model lane"
|
||||
>
|
||||
{(["primary", ...(assigneeSupportsCheapLane ? (["cheap"] as const) : ([] as const)), "custom"] as const).map((lane) => (
|
||||
{(["primary", "custom"] as const).map((lane) => (
|
||||
<button
|
||||
key={lane}
|
||||
type="button"
|
||||
|
|
@ -1945,24 +1914,10 @@ export function NewIssueDialog() {
|
|||
)}
|
||||
onClick={() => setAssigneeModelLane(lane)}
|
||||
>
|
||||
{lane === "primary"
|
||||
? "Primary"
|
||||
: lane === "cheap"
|
||||
? "Cheap"
|
||||
: "Custom"}
|
||||
{lane === "primary" ? "Primary" : "Custom"}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
{assigneeModelLane === "cheap" && (
|
||||
<p className="text-(length:--text-micro) text-muted-foreground">
|
||||
Sends <code>modelProfile: "cheap"</code>{" "}
|
||||
{assigneeCheapProfile?.adapterConfig && typeof (assigneeCheapProfile.adapterConfig as Record<string, unknown>).model === "string"
|
||||
? <>· adapter default <code>{String((assigneeCheapProfile.adapterConfig as Record<string, unknown>).model)}</code></>
|
||||
: assigneeCheapProfile
|
||||
? <>· uses the agent's configured cheap profile</>
|
||||
: <>· falls back to the primary model if no cheap profile is configured</>}
|
||||
</p>
|
||||
)}
|
||||
{assigneeModelLane === "primary" && (
|
||||
<p className="text-(length:--text-micro) text-muted-foreground">Runs on the agent's primary model.</p>
|
||||
)}
|
||||
|
|
|
|||
|
|
@ -92,7 +92,6 @@ vi.mock("../adapters/use-adapter-capabilities", () => ({
|
|||
supportsSkills: false,
|
||||
supportsLocalAgentJwt: false,
|
||||
requiresMaterializedRuntimeSkills: false,
|
||||
supportsModelProfiles: false,
|
||||
}),
|
||||
}));
|
||||
// Animation / canvas-ish children that add nothing to the logic under test.
|
||||
|
|
|
|||
|
|
@ -173,7 +173,6 @@ vi.mock("../adapters/use-adapter-capabilities", () => ({
|
|||
supportsSkills: false,
|
||||
supportsLocalAgentJwt: false,
|
||||
requiresMaterializedRuntimeSkills: false,
|
||||
supportsModelProfiles: false,
|
||||
login: ADAPTERS_WITH_LOGIN.has(type)
|
||||
? { panelMode: "displayed_code" as const, timeoutPolicy: "fixed" as const }
|
||||
: undefined,
|
||||
|
|
|
|||
|
|
@ -564,12 +564,6 @@ export function IssueProperties({
|
|||
const supportsAssigneeOverrides = Boolean(
|
||||
assigneeAdapterType && ISSUE_OVERRIDE_ADAPTER_TYPES.has(assigneeAdapterType),
|
||||
);
|
||||
const assigneeSupportsCheapLane = Boolean(
|
||||
supportsAssigneeOverrides
|
||||
&& (assigneeAdapterType === "claude_local"
|
||||
|| assigneeAdapterType === "codex_local"
|
||||
|| assigneeAdapterType === "opencode_local"),
|
||||
);
|
||||
const assigneeOverrideLane = overrideLane(assigneeAdapterOverrides);
|
||||
const assigneeOverrideAdapterConfig = asRecord(assigneeAdapterOverrides?.adapterConfig);
|
||||
const assigneeOverrideModel =
|
||||
|
|
@ -588,17 +582,6 @@ export function IssueProperties({
|
|||
queryFn: () => agentsApi.adapterModels(companyId!, assigneeAdapterType!),
|
||||
enabled: Boolean(companyId) && showAssigneeAdapterOptions && supportsAssigneeOverrides,
|
||||
});
|
||||
const { data: assigneeCheapProfiles } = useQuery({
|
||||
queryKey: companyId && assigneeAdapterType
|
||||
? queryKeys.agents.adapterModelProfiles(companyId, assigneeAdapterType)
|
||||
: ["agents", "none", "adapter-model-profiles", assigneeAdapterType ?? "none"],
|
||||
queryFn: () => agentsApi.adapterModelProfiles(companyId!, assigneeAdapterType!),
|
||||
enabled: Boolean(companyId) && showAssigneeAdapterOptions && assigneeSupportsCheapLane,
|
||||
});
|
||||
const assigneeCheapProfile = useMemo(
|
||||
() => (assigneeCheapProfiles ?? []).find((profile) => profile.key === "cheap") ?? null,
|
||||
[assigneeCheapProfiles],
|
||||
);
|
||||
const modelOverrideOptions = useMemo<InlineEntityOption[]>(() => {
|
||||
const models = sortAdapterModels(assigneeAdapterModels ?? []);
|
||||
const options = models.map((model) => ({
|
||||
|
|
@ -650,21 +633,9 @@ export function IssueProperties({
|
|||
updateAssigneeAdapterOverrides(null);
|
||||
return;
|
||||
}
|
||||
if (lane === "cheap") {
|
||||
updateAssigneeAdapterOverrides(
|
||||
compactRecord({
|
||||
useProjectWorkspace: assigneeAdapterOverrides?.useProjectWorkspace,
|
||||
modelProfile: "cheap",
|
||||
}),
|
||||
);
|
||||
return;
|
||||
}
|
||||
updateAssigneeAdapterOverrides(buildAssigneeOverrideWithConfig(assigneeOverrideAdapterConfig) ?? { adapterConfig: {} });
|
||||
};
|
||||
const assigneeOptionsTrigger = (() => {
|
||||
if (assigneeOverrideLane === "cheap") {
|
||||
return <span className="text-sm">Cheap model</span>;
|
||||
}
|
||||
if (assigneeOverrideLane === "custom") {
|
||||
const details = [
|
||||
assigneeOverrideModel,
|
||||
|
|
@ -688,7 +659,7 @@ export function IssueProperties({
|
|||
<div className="space-y-1.5">
|
||||
<div className="text-xs text-muted-foreground">Model lane</div>
|
||||
<div className="flex w-full overflow-hidden rounded-md border border-border" role="radiogroup" aria-label="Model lane">
|
||||
{(["primary", ...(assigneeSupportsCheapLane ? (["cheap"] as const) : ([] as const)), "custom"] as const).map((lane) => (
|
||||
{(["primary", "custom"] as const).map((lane) => (
|
||||
<button
|
||||
key={lane}
|
||||
type="button"
|
||||
|
|
@ -700,20 +671,10 @@ export function IssueProperties({
|
|||
)}
|
||||
onClick={() => setAssigneeOverrideLane(lane)}
|
||||
>
|
||||
{lane === "primary" ? "Primary" : lane === "cheap" ? "Cheap" : "Override"}
|
||||
{lane === "primary" ? "Primary" : "Override"}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
{assigneeOverrideLane === "cheap" ? (
|
||||
<p className="text-xs text-muted-foreground">
|
||||
Sends <code>modelProfile: "cheap"</code>{" "}
|
||||
{assigneeCheapProfile?.adapterConfig && typeof (assigneeCheapProfile.adapterConfig as Record<string, unknown>).model === "string"
|
||||
? <>· adapter default <code>{String((assigneeCheapProfile.adapterConfig as Record<string, unknown>).model)}</code></>
|
||||
: assigneeCheapProfile
|
||||
? <>· uses the agent's configured cheap profile</>
|
||||
: <>· falls back to the primary model if no cheap profile is configured</>}
|
||||
</p>
|
||||
) : null}
|
||||
{assigneeOverrideLane === "custom" ? (
|
||||
<p className="text-xs text-muted-foreground">
|
||||
Task-level model override — replaces the agent's primary model for this issue.
|
||||
|
|
|
|||
|
|
@ -113,7 +113,6 @@ export function thinkingEffortValueFor(adapterType: string | null | undefined, a
|
|||
}
|
||||
|
||||
export function overrideLane(overrides: Issue["assigneeAdapterOverrides"]): IssueModelLane {
|
||||
if (overrides?.modelProfile === "cheap") return "cheap";
|
||||
if (overrides?.adapterConfig) return "custom";
|
||||
return "primary";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,7 +37,6 @@ vi.mock("@/adapters/use-adapter-capabilities", () => ({
|
|||
supportsSkills: true,
|
||||
supportsLocalAgentJwt: true,
|
||||
requiresMaterializedRuntimeSkills: false,
|
||||
supportsModelProfiles: false,
|
||||
}),
|
||||
}));
|
||||
vi.mock("@/context/ToastContext", () => ({
|
||||
|
|
|
|||
|
|
@ -92,37 +92,6 @@ describe("buildAgentUpdatePatch", () => {
|
|||
});
|
||||
});
|
||||
|
||||
it("writes the cheap profile under runtimeConfig.modelProfiles, never on primary adapterConfig", () => {
|
||||
const patch = buildAgentUpdatePatch(
|
||||
makeAgent(),
|
||||
makeOverlay({
|
||||
modelProfiles: {
|
||||
cheap: {
|
||||
enabled: true,
|
||||
adapterConfig: { model: "claude-haiku-4-5" },
|
||||
},
|
||||
},
|
||||
}),
|
||||
);
|
||||
|
||||
expect(patch).toEqual({
|
||||
runtimeConfig: {
|
||||
heartbeat: {
|
||||
enabled: true,
|
||||
intervalSec: 300,
|
||||
},
|
||||
modelProfiles: {
|
||||
cheap: {
|
||||
enabled: true,
|
||||
adapterConfig: { model: "claude-haiku-4-5" },
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
// The primary adapterConfig is untouched.
|
||||
expect(patch.adapterConfig).toBeUndefined();
|
||||
});
|
||||
|
||||
it("writes max-turn continuation policy under runtimeConfig.heartbeat", () => {
|
||||
const patch = buildAgentUpdatePatch(
|
||||
makeAgent(),
|
||||
|
|
@ -152,61 +121,6 @@ describe("buildAgentUpdatePatch", () => {
|
|||
});
|
||||
});
|
||||
|
||||
it("merges cheap profile changes onto existing runtimeConfig.modelProfiles state", () => {
|
||||
const agent = makeAgent();
|
||||
agent.runtimeConfig = {
|
||||
heartbeat: { enabled: true, intervalSec: 300 },
|
||||
modelProfiles: {
|
||||
cheap: {
|
||||
enabled: false,
|
||||
adapterConfig: { model: "old-cheap" },
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
const patch = buildAgentUpdatePatch(
|
||||
agent,
|
||||
makeOverlay({
|
||||
modelProfiles: {
|
||||
cheap: {
|
||||
enabled: true,
|
||||
},
|
||||
},
|
||||
}),
|
||||
);
|
||||
|
||||
expect((patch.runtimeConfig as Record<string, unknown>).modelProfiles).toEqual({
|
||||
cheap: {
|
||||
enabled: true,
|
||||
adapterConfig: { model: "old-cheap" },
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
it("clears the cheap profile when the overlay marks it cleared", () => {
|
||||
const agent = makeAgent();
|
||||
agent.runtimeConfig = {
|
||||
heartbeat: { enabled: true, intervalSec: 300 },
|
||||
modelProfiles: {
|
||||
cheap: {
|
||||
enabled: true,
|
||||
adapterConfig: { model: "claude-haiku-4-5" },
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
const patch = buildAgentUpdatePatch(
|
||||
agent,
|
||||
makeOverlay({
|
||||
modelProfiles: { cheap: { cleared: true } },
|
||||
}),
|
||||
);
|
||||
|
||||
expect(patch.runtimeConfig).toEqual({
|
||||
heartbeat: { enabled: true, intervalSec: 300 },
|
||||
});
|
||||
});
|
||||
|
||||
it("preserves adapter-agnostic keys when changing adapter types", () => {
|
||||
const patch = buildAgentUpdatePatch(
|
||||
makeAgent(),
|
||||
|
|
|
|||
|
|
@ -1,15 +1,5 @@
|
|||
import { ADAPTER_AGNOSTIC_KEYS, type Agent } from "@paperclipai/shared";
|
||||
|
||||
export interface AgentModelProfileOverlay {
|
||||
enabled?: boolean;
|
||||
adapterConfig?: Record<string, unknown>;
|
||||
/**
|
||||
* Mark the cheap profile for clearing. When true, the patch removes
|
||||
* `runtimeConfig.modelProfiles.cheap` instead of merging into it.
|
||||
*/
|
||||
cleared?: boolean;
|
||||
}
|
||||
|
||||
export interface AgentConfigOverlay {
|
||||
identity: Record<string, unknown>;
|
||||
adapterType?: string;
|
||||
|
|
@ -17,7 +7,6 @@ export interface AgentConfigOverlay {
|
|||
heartbeat: Record<string, unknown>;
|
||||
debug: Record<string, unknown>;
|
||||
runtime: Record<string, unknown>;
|
||||
modelProfiles?: { cheap?: AgentModelProfileOverlay };
|
||||
}
|
||||
|
||||
export function omitUndefinedEntries(value: Record<string, unknown>) {
|
||||
|
|
@ -58,13 +47,9 @@ export function buildAgentUpdatePatch(agent: Agent, overlay: AgentConfigOverlay)
|
|||
patch.replaceAdapterConfig = true;
|
||||
}
|
||||
|
||||
const cheapOverlay = overlay.modelProfiles?.cheap;
|
||||
const hasModelProfileChange = cheapOverlay !== undefined;
|
||||
|
||||
if (
|
||||
Object.keys(overlay.heartbeat).length > 0
|
||||
|| Object.keys(overlay.debug).length > 0
|
||||
|| hasModelProfileChange
|
||||
) {
|
||||
const existingRc = (agent.runtimeConfig ?? {}) as Record<string, unknown>;
|
||||
const nextRuntimeConfig: Record<string, unknown> = (patch.runtimeConfig as Record<string, unknown> | undefined)
|
||||
|
|
@ -85,33 +70,6 @@ export function buildAgentUpdatePatch(agent: Agent, overlay: AgentConfigOverlay)
|
|||
}
|
||||
}
|
||||
|
||||
if (hasModelProfileChange) {
|
||||
const existingProfiles = ((existingRc.modelProfiles ?? {}) as Record<string, unknown>);
|
||||
const existingCheap = ((existingProfiles.cheap ?? {}) as Record<string, unknown>);
|
||||
const nextProfiles = { ...existingProfiles };
|
||||
|
||||
if (cheapOverlay?.cleared) {
|
||||
delete nextProfiles.cheap;
|
||||
} else if (cheapOverlay) {
|
||||
const mergedAdapterConfig = {
|
||||
...((existingCheap.adapterConfig ?? {}) as Record<string, unknown>),
|
||||
...(cheapOverlay.adapterConfig ?? {}),
|
||||
};
|
||||
const enabled = cheapOverlay.enabled ?? (existingCheap.enabled !== false);
|
||||
nextProfiles.cheap = {
|
||||
...existingCheap,
|
||||
enabled,
|
||||
adapterConfig: mergedAdapterConfig,
|
||||
};
|
||||
}
|
||||
|
||||
if (Object.keys(nextProfiles).length === 0) {
|
||||
delete nextRuntimeConfig.modelProfiles;
|
||||
} else {
|
||||
nextRuntimeConfig.modelProfiles = nextProfiles;
|
||||
}
|
||||
}
|
||||
|
||||
patch.runtimeConfig = nextRuntimeConfig;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -28,18 +28,6 @@ describe("buildAssigneeAdapterOverrides", () => {
|
|||
).toBeNull();
|
||||
});
|
||||
|
||||
it("cheap lane sends modelProfile=cheap and no adapterConfig", () => {
|
||||
expect(
|
||||
buildAssigneeAdapterOverrides({
|
||||
adapterType: "codex_local",
|
||||
lane: "cheap",
|
||||
modelOverride: "ignored",
|
||||
thinkingEffortOverride: "high",
|
||||
chrome: false,
|
||||
}),
|
||||
).toEqual({ modelProfile: "cheap" });
|
||||
});
|
||||
|
||||
it("custom lane preserves explicit model + thinking effort + chrome overrides", () => {
|
||||
expect(
|
||||
buildAssigneeAdapterOverrides({
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ export const ISSUE_OVERRIDE_ADAPTER_TYPES = new Set([
|
|||
"opencode_local",
|
||||
]);
|
||||
|
||||
export type IssueModelLane = "primary" | "cheap" | "custom";
|
||||
export type IssueModelLane = "primary" | "custom";
|
||||
|
||||
export interface BuildAssigneeAdapterOverridesInput {
|
||||
adapterType: string | null | undefined;
|
||||
|
|
@ -19,8 +19,6 @@ export interface BuildAssigneeAdapterOverridesInput {
|
|||
*
|
||||
* Lane semantics:
|
||||
* - "primary" → no overrides, runs on the agent's primary model.
|
||||
* - "cheap" → `modelProfile: "cheap"` only; the runtime resolves the actual
|
||||
* adapter config from the agent's runtimeConfig + adapter default.
|
||||
* - "custom" → preserves the legacy explicit override path
|
||||
* (`adapterConfig.model`, thinking effort, chrome).
|
||||
*/
|
||||
|
|
@ -36,10 +34,6 @@ export function buildAssigneeAdapterOverrides(
|
|||
return null;
|
||||
}
|
||||
|
||||
if (input.lane === "cheap") {
|
||||
return { modelProfile: "cheap" };
|
||||
}
|
||||
|
||||
const adapterConfig: Record<string, unknown> = {};
|
||||
if (input.modelOverride) adapterConfig.model = input.modelOverride;
|
||||
if (input.thinkingEffortOverride) {
|
||||
|
|
|
|||
|
|
@ -35,8 +35,6 @@ export function buildNewAgentHirePayload(input: {
|
|||
runtimeConfig: buildNewAgentRuntimeConfig({
|
||||
heartbeatEnabled: configValues.heartbeatEnabled,
|
||||
intervalSec: configValues.intervalSec,
|
||||
cheapModel: configValues.cheapModel,
|
||||
cheapModelEnabled: configValues.cheapModelEnabled,
|
||||
}),
|
||||
budgetMonthlyCents: 0,
|
||||
...(permissions ? { permissions } : {}),
|
||||
|
|
|
|||
|
|
@ -34,47 +34,4 @@ describe("buildNewAgentRuntimeConfig", () => {
|
|||
},
|
||||
});
|
||||
});
|
||||
|
||||
it("stores cheap model under modelProfiles.cheap, not primary adapterConfig", () => {
|
||||
const config = buildNewAgentRuntimeConfig({
|
||||
heartbeatEnabled: true,
|
||||
intervalSec: 600,
|
||||
cheapModel: "claude-sonnet-4-6",
|
||||
cheapModelEnabled: true,
|
||||
});
|
||||
|
||||
expect(config.modelProfiles).toEqual({
|
||||
cheap: {
|
||||
enabled: true,
|
||||
adapterConfig: { model: "claude-sonnet-4-6" },
|
||||
},
|
||||
});
|
||||
// primary heartbeat config still present
|
||||
expect(config.heartbeat).toMatchObject({ enabled: true, intervalSec: 600 });
|
||||
});
|
||||
|
||||
it("omits modelProfiles when no cheap model is configured", () => {
|
||||
const config = buildNewAgentRuntimeConfig({ heartbeatEnabled: false });
|
||||
expect(config.modelProfiles).toBeUndefined();
|
||||
});
|
||||
|
||||
it("persists explicit cheap-profile opt-in when using the adapter default", () => {
|
||||
const config = buildNewAgentRuntimeConfig({
|
||||
cheapModelEnabled: true,
|
||||
});
|
||||
expect(config.modelProfiles).toEqual({
|
||||
cheap: {
|
||||
enabled: true,
|
||||
adapterConfig: {},
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
it("omits modelProfiles when cheap model is set but explicitly disabled", () => {
|
||||
const config = buildNewAgentRuntimeConfig({
|
||||
cheapModel: "claude-sonnet-4-6",
|
||||
cheapModelEnabled: false,
|
||||
});
|
||||
expect(config.modelProfiles).toBeUndefined();
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -4,8 +4,6 @@ import { defaultCreateValues } from "../components/agent-config-defaults";
|
|||
export function buildNewAgentRuntimeConfig(input?: {
|
||||
heartbeatEnabled?: boolean;
|
||||
intervalSec?: number;
|
||||
cheapModel?: string;
|
||||
cheapModelEnabled?: boolean;
|
||||
}): Record<string, unknown> {
|
||||
const config: Record<string, unknown> = {
|
||||
heartbeat: {
|
||||
|
|
@ -18,16 +16,5 @@ export function buildNewAgentRuntimeConfig(input?: {
|
|||
},
|
||||
};
|
||||
|
||||
const cheapModel = input?.cheapModel?.trim() ?? "";
|
||||
const cheapEnabled = input?.cheapModelEnabled ?? false;
|
||||
if (cheapEnabled) {
|
||||
config.modelProfiles = {
|
||||
cheap: {
|
||||
enabled: true,
|
||||
adapterConfig: cheapModel ? { model: cheapModel } : {},
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
return config;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -216,8 +216,6 @@ export const queryKeys = {
|
|||
adapterType,
|
||||
environmentId ?? null,
|
||||
] as const,
|
||||
adapterModelProfiles: (companyId: string, adapterType: string) =>
|
||||
["agents", companyId, "adapter-model-profiles", adapterType] as const,
|
||||
detectModel: (companyId: string, adapterType: string) =>
|
||||
["agents", companyId, "detect-model", adapterType] as const,
|
||||
authSignal: (companyId: string, adapterType: string, environmentId?: string | null) =>
|
||||
|
|
|
|||
|
|
@ -621,7 +621,6 @@ export function AdapterManager() {
|
|||
supportsSkills: false,
|
||||
supportsLocalAgentJwt: false,
|
||||
requiresMaterializedRuntimeSkills: false,
|
||||
supportsModelProfiles: false,
|
||||
supportsAcp: false,
|
||||
},
|
||||
}}
|
||||
|
|
|
|||
|
|
@ -42,7 +42,6 @@ vi.mock("@/adapters/use-adapter-capabilities", () => ({
|
|||
supportsSkills: true,
|
||||
supportsLocalAgentJwt: true,
|
||||
requiresMaterializedRuntimeSkills: false,
|
||||
supportsModelProfiles: true,
|
||||
}),
|
||||
}));
|
||||
|
||||
|
|
|
|||
|
|
@ -14,7 +14,6 @@ import { NewAgent } from "./NewAgent";
|
|||
// `env` map, which is the contract this page test verifies.
|
||||
|
||||
const mockAgentsApi = vi.hoisted(() => ({
|
||||
adapterModelProfiles: vi.fn(),
|
||||
adapterModels: vi.fn(),
|
||||
detectModel: vi.fn(),
|
||||
list: vi.fn(),
|
||||
|
|
@ -102,7 +101,6 @@ vi.mock("../adapters/use-adapter-capabilities", () => ({
|
|||
supportsSkills: true,
|
||||
supportsLocalAgentJwt: true,
|
||||
requiresMaterializedRuntimeSkills: false,
|
||||
supportsModelProfiles: true,
|
||||
supportsAcp: true,
|
||||
...(login ? { login } : {}),
|
||||
};
|
||||
|
|
@ -244,7 +242,6 @@ describe("NewAgent Claude subscription login", () => {
|
|||
mockAdapterAvailability.disabled = new Set<string>();
|
||||
mockAdapterAvailability.loaded = true;
|
||||
mockSearchParams.value = new URLSearchParams();
|
||||
mockAgentsApi.adapterModelProfiles.mockResolvedValue([]);
|
||||
mockAgentsApi.adapterModels.mockResolvedValue([]);
|
||||
mockAgentsApi.detectModel.mockResolvedValue(null);
|
||||
// No existing agents: the page treats the new agent as the first (CEO) and
|
||||
|
|
|
|||
|
|
@ -338,7 +338,6 @@ const adapterFixtures: AdapterInfo[] = [
|
|||
supportsSkills: true,
|
||||
supportsLocalAgentJwt: true,
|
||||
requiresMaterializedRuntimeSkills: true,
|
||||
supportsModelProfiles: true,
|
||||
supportsAcp: true,
|
||||
},
|
||||
},
|
||||
|
|
@ -354,7 +353,6 @@ const adapterFixtures: AdapterInfo[] = [
|
|||
supportsSkills: true,
|
||||
supportsLocalAgentJwt: true,
|
||||
requiresMaterializedRuntimeSkills: true,
|
||||
supportsModelProfiles: true,
|
||||
supportsAcp: true,
|
||||
},
|
||||
},
|
||||
|
|
@ -370,7 +368,6 @@ const adapterFixtures: AdapterInfo[] = [
|
|||
supportsSkills: false,
|
||||
supportsLocalAgentJwt: false,
|
||||
requiresMaterializedRuntimeSkills: false,
|
||||
supportsModelProfiles: false,
|
||||
supportsAcp: false,
|
||||
},
|
||||
},
|
||||
|
|
|
|||
|
|
@ -384,7 +384,6 @@ function hydrateDialogQueries(queryClient: ReturnType<typeof useQueryClient>) {
|
|||
supportsSkills: true,
|
||||
supportsLocalAgentJwt: true,
|
||||
requiresMaterializedRuntimeSkills: false,
|
||||
supportsModelProfiles: true,
|
||||
supportsAcp: true,
|
||||
},
|
||||
},
|
||||
|
|
@ -400,7 +399,6 @@ function hydrateDialogQueries(queryClient: ReturnType<typeof useQueryClient>) {
|
|||
supportsSkills: true,
|
||||
supportsLocalAgentJwt: true,
|
||||
requiresMaterializedRuntimeSkills: false,
|
||||
supportsModelProfiles: true,
|
||||
supportsAcp: true,
|
||||
},
|
||||
},
|
||||
|
|
@ -409,41 +407,8 @@ function hydrateDialogQueries(queryClient: ReturnType<typeof useQueryClient>) {
|
|||
{ id: "gpt-5.4", label: "GPT-5.4" },
|
||||
{ id: "gpt-5.4-mini", label: "GPT-5.4 Mini" },
|
||||
]);
|
||||
queryClient.setQueryData(queryKeys.agents.adapterModelProfiles(COMPANY_ID, "codex_local"), [
|
||||
{
|
||||
key: "cheap",
|
||||
label: "Cheap",
|
||||
adapterConfig: { model: "gpt-5.4-mini" },
|
||||
source: "adapter_default",
|
||||
},
|
||||
]);
|
||||
}
|
||||
|
||||
const HERMES_AGENT: Agent = {
|
||||
id: "agent-hermes",
|
||||
companyId: COMPANY_ID,
|
||||
name: "HermesRouter",
|
||||
urlKey: "hermesrouter",
|
||||
role: "engineer",
|
||||
title: "Lightweight Routing",
|
||||
icon: "code",
|
||||
status: "idle",
|
||||
reportsTo: "agent-cto",
|
||||
capabilities: "Hermes-backed assistant on an adapter without the cheap-profile contract.",
|
||||
adapterType: "opencode_local",
|
||||
adapterConfig: {},
|
||||
runtimeConfig: {},
|
||||
budgetMonthlyCents: 60_000,
|
||||
spentMonthlyCents: 9_000,
|
||||
pauseReason: null,
|
||||
pausedAt: null,
|
||||
permissions: { canCreateAgents: false },
|
||||
lastHeartbeatAt: new Date("2026-04-29T08:30:00.000Z"),
|
||||
metadata: null,
|
||||
createdAt: new Date("2026-04-12T08:00:00.000Z"),
|
||||
updatedAt: new Date("2026-04-29T08:30:00.000Z"),
|
||||
};
|
||||
|
||||
function StorybookDialogFixtures({ children }: { children: ReactNode }) {
|
||||
const queryClient = useQueryClient();
|
||||
const [ready] = useState(() => {
|
||||
|
|
@ -694,130 +659,6 @@ function ImageGalleryModalStory() {
|
|||
);
|
||||
}
|
||||
|
||||
type CheapLaneVariant = "primary" | "cheap" | "custom" | "unsupported";
|
||||
|
||||
function clickModelLaneButton(label: "Primary" | "Cheap" | "Custom") {
|
||||
const radiogroup = document.querySelector<HTMLElement>("[aria-label='Model lane']");
|
||||
if (!radiogroup) return false;
|
||||
const buttons = Array.from(radiogroup.querySelectorAll<HTMLButtonElement>("button[role='radio']"));
|
||||
const button = buttons.find((candidate) => candidate.textContent?.trim() === label);
|
||||
if (!button) return false;
|
||||
button.click();
|
||||
return true;
|
||||
}
|
||||
|
||||
function findAssigneeOptionsButton() {
|
||||
const buttons = Array.from(document.querySelectorAll<HTMLButtonElement>("button"));
|
||||
return (
|
||||
buttons.find((candidate) => /(Codex|Claude|OpenCode|Agent) options$/.test(candidate.textContent?.trim() ?? "")) ?? null
|
||||
);
|
||||
}
|
||||
|
||||
function useCheapLaneAdapterOverrides(variant: CheapLaneVariant) {
|
||||
const queryClient = useQueryClient();
|
||||
useLayoutEffect(() => {
|
||||
if (variant !== "unsupported") return;
|
||||
queryClient.setQueryData(
|
||||
queryKeys.agents.list(COMPANY_ID),
|
||||
[...storybookAgents, HERMES_AGENT],
|
||||
);
|
||||
queryClient.setQueryData(queryKeys.adapters.all, [
|
||||
{
|
||||
type: "codex_local",
|
||||
label: "Codex",
|
||||
source: "builtin",
|
||||
modelsCount: 5,
|
||||
loaded: true,
|
||||
disabled: false,
|
||||
capabilities: {
|
||||
supportsInstructionsBundle: true,
|
||||
supportsSkills: true,
|
||||
supportsLocalAgentJwt: true,
|
||||
requiresMaterializedRuntimeSkills: false,
|
||||
supportsModelProfiles: true,
|
||||
supportsAcp: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
type: "opencode_local",
|
||||
label: "OpenCode",
|
||||
source: "builtin",
|
||||
modelsCount: 2,
|
||||
loaded: true,
|
||||
disabled: false,
|
||||
capabilities: {
|
||||
supportsInstructionsBundle: true,
|
||||
supportsSkills: true,
|
||||
supportsLocalAgentJwt: true,
|
||||
requiresMaterializedRuntimeSkills: true,
|
||||
supportsModelProfiles: false,
|
||||
supportsAcp: false,
|
||||
},
|
||||
},
|
||||
]);
|
||||
queryClient.setQueryData(queryKeys.agents.adapterModels(COMPANY_ID, "opencode_local"), [
|
||||
{ id: "anthropic/claude-haiku-4-5", label: "Claude Haiku 4.5" },
|
||||
{ id: "openai/gpt-5.4-mini", label: "GPT-5.4 Mini" },
|
||||
]);
|
||||
}, [queryClient, variant]);
|
||||
}
|
||||
|
||||
function CheapLaneIssueDialogOpener({ variant }: { variant: CheapLaneVariant }) {
|
||||
const { openNewIssue } = useDialog();
|
||||
useCheapLaneAdapterOverrides(variant);
|
||||
|
||||
const assigneeAgentId = variant === "unsupported" ? "agent-hermes" : "agent-codex";
|
||||
const title =
|
||||
variant === "unsupported"
|
||||
? "Route research summary to HermesRouter"
|
||||
: "Generate weekly Storybook coverage report";
|
||||
const description =
|
||||
variant === "unsupported"
|
||||
? "HermesRouter runs on an adapter that does not advertise a cheap profile, so the Cheap lane should disappear instead of being greyed."
|
||||
: "Lower-cost runs should still pick up the agent's cheap profile so the model badge can show the requested lane.";
|
||||
|
||||
useOpenWhenCompanyReady(() => {
|
||||
openNewIssue({
|
||||
title,
|
||||
description,
|
||||
status: "todo",
|
||||
priority: "medium",
|
||||
projectId: "project-board-ui",
|
||||
projectWorkspaceId: "workspace-board-ui",
|
||||
assigneeAgentId,
|
||||
});
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
let cancelled = false;
|
||||
const timers: number[] = [];
|
||||
|
||||
timers.push(
|
||||
window.setTimeout(() => {
|
||||
if (cancelled) return;
|
||||
const optionsButton = findAssigneeOptionsButton();
|
||||
optionsButton?.click();
|
||||
}, 300),
|
||||
);
|
||||
|
||||
if (variant === "cheap" || variant === "custom") {
|
||||
timers.push(
|
||||
window.setTimeout(() => {
|
||||
if (cancelled) return;
|
||||
clickModelLaneButton(variant === "cheap" ? "Cheap" : "Custom");
|
||||
}, 600),
|
||||
);
|
||||
}
|
||||
|
||||
return () => {
|
||||
cancelled = true;
|
||||
for (const timer of timers) window.clearTimeout(timer);
|
||||
};
|
||||
}, [variant]);
|
||||
|
||||
return <NewIssueDialog />;
|
||||
}
|
||||
|
||||
function PathInstructionsModalStory() {
|
||||
return (
|
||||
<DialogStory
|
||||
|
|
@ -889,62 +730,6 @@ export const NewIssueValidationError: Story = {
|
|||
),
|
||||
};
|
||||
|
||||
export const NewIssueCheapLanePrimary: Story = {
|
||||
name: "New Issue - Cheap lane (Primary)",
|
||||
render: () => (
|
||||
<DialogStory
|
||||
eyebrow="NewIssueDialog"
|
||||
title="Model lane segmented control - Primary selected"
|
||||
description="Codex assignee with the assignee-options drawer expanded so the Primary | Cheap | Custom segmented control is visible. Default helper copy is shown."
|
||||
badges={["model lane", "primary", "default"]}
|
||||
>
|
||||
<CheapLaneIssueDialogOpener variant="primary" />
|
||||
</DialogStory>
|
||||
),
|
||||
};
|
||||
|
||||
export const NewIssueCheapLaneCheap: Story = {
|
||||
name: "New Issue - Cheap lane (Cheap)",
|
||||
render: () => (
|
||||
<DialogStory
|
||||
eyebrow="NewIssueDialog"
|
||||
title="Model lane segmented control - Cheap selected"
|
||||
description='Codex assignee with the Cheap lane selected so the helper line "Sends modelProfile: \"cheap\" · adapter default …" is visible.'
|
||||
badges={["model lane", "cheap", "modelProfile"]}
|
||||
>
|
||||
<CheapLaneIssueDialogOpener variant="cheap" />
|
||||
</DialogStory>
|
||||
),
|
||||
};
|
||||
|
||||
export const NewIssueCheapLaneCustom: Story = {
|
||||
name: "New Issue - Cheap lane (Custom)",
|
||||
render: () => (
|
||||
<DialogStory
|
||||
eyebrow="NewIssueDialog"
|
||||
title="Model lane segmented control - Custom selected"
|
||||
description="Custom selected so the explicit model picker and thinking-effort sub-fields render the way they did before the cheap lane was added."
|
||||
badges={["model lane", "custom", "regression"]}
|
||||
>
|
||||
<CheapLaneIssueDialogOpener variant="custom" />
|
||||
</DialogStory>
|
||||
),
|
||||
};
|
||||
|
||||
export const NewIssueCheapLaneUnsupported: Story = {
|
||||
name: "New Issue - Cheap lane (Unsupported adapter)",
|
||||
render: () => (
|
||||
<DialogStory
|
||||
eyebrow="NewIssueDialog"
|
||||
title="Model lane on an adapter without supportsModelProfiles"
|
||||
description="HermesRouter runs on opencode_local with supportsModelProfiles disabled, so the Cheap option should be hidden — the segmented control collapses to Primary | Custom rather than showing a greyed Cheap entry."
|
||||
badges={["model lane", "unsupported", "cheap hidden"]}
|
||||
>
|
||||
<CheapLaneIssueDialogOpener variant="unsupported" />
|
||||
</DialogStory>
|
||||
),
|
||||
};
|
||||
|
||||
export const NewAgentRecommendation: Story = {
|
||||
name: "New Agent - Recommendation",
|
||||
render: () => (
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue