refactor(background-agent): normalize task ID field naming
Rename BackgroundTask and attempt ID fields to camelCase across background-agent consumers while moving BackgroundManager construction to a single config object. Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
@@ -69,8 +69,8 @@ function createMockTask(overrides: Partial<BackgroundTask> = {}): BackgroundTask
|
||||
prompt: "test prompt",
|
||||
agent: "sisyphus-junior",
|
||||
status: "error",
|
||||
parentSessionID: "parent-session-1",
|
||||
parentMessageID: "parent-message-1",
|
||||
parentSessionId: "parent-session-1",
|
||||
parentMessageId: "parent-message-1",
|
||||
fallbackChain: [
|
||||
{ model: "fallback-model-1", providers: ["provider-a"], variant: undefined },
|
||||
{ model: "fallback-model-2", providers: ["provider-b"], variant: undefined },
|
||||
@@ -174,13 +174,13 @@ describe("tryFallbackRetry", () => {
|
||||
|
||||
test("clears sessionID and startedAt", async () => {
|
||||
const args = createDefaultArgs({
|
||||
sessionID: "old-session",
|
||||
sessionId: "old-session",
|
||||
startedAt: new Date(),
|
||||
})
|
||||
|
||||
await tryFallbackRetry(args)
|
||||
|
||||
expect(args.task.sessionID).toBeUndefined()
|
||||
expect(args.task.sessionId).toBeUndefined()
|
||||
expect(args.task.startedAt).toBeUndefined()
|
||||
})
|
||||
|
||||
@@ -217,7 +217,7 @@ describe("tryFallbackRetry", () => {
|
||||
})
|
||||
|
||||
test("aborts existing session", async () => {
|
||||
const args = createDefaultArgs({ sessionID: "session-to-abort" })
|
||||
const args = createDefaultArgs({ sessionId: "session-to-abort" })
|
||||
|
||||
await tryFallbackRetry(args)
|
||||
|
||||
@@ -227,7 +227,7 @@ describe("tryFallbackRetry", () => {
|
||||
})
|
||||
|
||||
test("waits for session abort before resolving", async () => {
|
||||
const args = createDefaultArgs({ sessionID: "session-to-abort" })
|
||||
const args = createDefaultArgs({ sessionId: "session-to-abort" })
|
||||
const deferred = createDeferredPromise()
|
||||
args.abortMock.mockImplementationOnce(() => deferred.promise)
|
||||
|
||||
@@ -263,15 +263,15 @@ describe("tryFallbackRetry", () => {
|
||||
test("finalizes the failed attempt, creates a new pending attempt, and enqueues its explicit attemptID", async () => {
|
||||
const args = createDefaultArgs({
|
||||
status: "running",
|
||||
sessionID: "session-attempt-1",
|
||||
sessionId: "session-attempt-1",
|
||||
startedAt: new Date("2026-04-27T00:00:00.000Z"),
|
||||
attempts: [
|
||||
{
|
||||
attemptID: "attempt-1",
|
||||
attemptId: "attempt-1",
|
||||
attemptNumber: 1,
|
||||
sessionID: "session-attempt-1",
|
||||
providerID: "provider-a",
|
||||
modelID: "original-model",
|
||||
sessionId: "session-attempt-1",
|
||||
providerId: "provider-a",
|
||||
modelId: "original-model",
|
||||
status: "running",
|
||||
startedAt: new Date("2026-04-27T00:00:00.000Z"),
|
||||
},
|
||||
@@ -283,8 +283,8 @@ describe("tryFallbackRetry", () => {
|
||||
|
||||
expect(args.task.attempts).toHaveLength(2)
|
||||
expect(args.task.attempts?.[0]).toMatchObject({
|
||||
attemptID: "attempt-1",
|
||||
sessionID: "session-attempt-1",
|
||||
attemptId: "attempt-1",
|
||||
sessionId: "session-attempt-1",
|
||||
status: "error",
|
||||
error: "model overloaded",
|
||||
})
|
||||
@@ -293,11 +293,11 @@ describe("tryFallbackRetry", () => {
|
||||
const nextAttempt = args.task.attempts?.[1]
|
||||
expect(nextAttempt).toBeDefined()
|
||||
expect(nextAttempt?.attemptNumber).toBe(2)
|
||||
expect(nextAttempt?.providerID).toBe("provider-a")
|
||||
expect(nextAttempt?.modelID).toBe("fallback-model-1")
|
||||
expect(nextAttempt?.providerId).toBe("provider-a")
|
||||
expect(nextAttempt?.modelId).toBe("fallback-model-1")
|
||||
expect(nextAttempt?.status).toBe("pending")
|
||||
|
||||
expect(args.task.currentAttemptID).toBe(nextAttempt?.attemptID)
|
||||
expect(args.task.currentAttemptID).toBe(nextAttempt?.attemptId)
|
||||
expect(args.task.status).toBe("pending")
|
||||
expect(args.task.model).toEqual({
|
||||
providerID: "provider-a",
|
||||
@@ -308,7 +308,7 @@ describe("tryFallbackRetry", () => {
|
||||
const key = `${args.task.model!.providerID}/${args.task.model!.modelID}`
|
||||
const queue = args.queuesByKey.get(key)
|
||||
expect(queue).toBeDefined()
|
||||
expect((queue?.[0] as QueueItem & { attemptID?: string })?.attemptID).toBe(nextAttempt?.attemptID)
|
||||
expect((queue?.[0] as QueueItem & { attemptID?: string })?.attemptID).toBe(nextAttempt?.attemptId)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -363,7 +363,7 @@ describe("tryFallbackRetry", () => {
|
||||
|
||||
describe("#given task without session", () => {
|
||||
test("skips session abort", async () => {
|
||||
const args = createDefaultArgs({ sessionID: undefined })
|
||||
const args = createDefaultArgs({ sessionId: undefined })
|
||||
|
||||
await tryFallbackRetry(args)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user