fix(server): decouple explicit and auto agent title limits (#78)

This commit is contained in:
Mohamed Boudra
2026-02-24 11:36:19 +08:00
committed by GitHub
parent 3f06063b4b
commit 5c773371d6
5 changed files with 135 additions and 5 deletions
@@ -1,5 +1,6 @@
import { describe, expect, it } from "vitest";
import { SessionInboundMessageSchema } from "./messages";
import { MAX_EXPLICIT_AGENT_TITLE_CHARS } from "../server/agent/agent-title-limits.js";
describe("create_agent_request clientMessageId", () => {
it("accepts clientMessageId for stable initial prompt transfer", () => {
@@ -20,4 +21,36 @@ describe("create_agent_request clientMessageId", () => {
}
expect(parsed.clientMessageId).toBe("client-msg-1");
});
it("accepts explicit titles up to the create-agent limit", () => {
const parsed = SessionInboundMessageSchema.parse({
type: "create_agent_request",
requestId: "req-title-ok",
config: {
provider: "claude",
cwd: "/tmp/project",
title: "x".repeat(MAX_EXPLICIT_AGENT_TITLE_CHARS),
},
});
expect(parsed.type).toBe("create_agent_request");
if (parsed.type !== "create_agent_request") {
throw new Error("Expected create_agent_request");
}
expect(parsed.config.title).toHaveLength(MAX_EXPLICIT_AGENT_TITLE_CHARS);
});
it("rejects explicit titles longer than the create-agent limit", () => {
const parsed = SessionInboundMessageSchema.safeParse({
type: "create_agent_request",
requestId: "req-title-too-long",
config: {
provider: "claude",
cwd: "/tmp/project",
title: "x".repeat(MAX_EXPLICIT_AGENT_TITLE_CHARS + 1),
},
});
expect(parsed.success).toBe(false);
});
});
+2 -1
View File
@@ -1,5 +1,6 @@
import { z } from 'zod'
import { AGENT_LIFECYCLE_STATUSES } from './agent-lifecycle.js'
import { MAX_EXPLICIT_AGENT_TITLE_CHARS } from '../server/agent/agent-title-limits.js'
import { AgentProviderSchema } from '../server/agent/provider-manifest.js'
import type {
AgentCapabilityFlags,
@@ -89,7 +90,7 @@ const AgentSessionConfigSchema = z.object({
modeId: z.string().optional(),
model: z.string().optional(),
thinkingOptionId: z.string().optional(),
title: z.string().trim().min(1).max(40).optional().nullable(),
title: z.string().trim().min(1).max(MAX_EXPLICIT_AGENT_TITLE_CHARS).optional().nullable(),
approvalPolicy: z.string().optional(),
sandboxMode: z.string().optional(),
networkAccess: z.boolean().optional(),