Skip to content

Commit 444b7ce

Browse files
committed
fix(sisyphus-task): guard client.session.get and update sync mode tests
- Add guard clause to check if client.session.get exists before calling - Update 4 sync mode tests to properly mock session.get - Fixes test failures from PR #731 directory inheritance feature
1 parent 31c5951 commit 444b7ce

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

src/tools/sisyphus-task/tools.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -452,6 +452,7 @@ describe("sisyphus-task", () => {
452452

453453
const mockClient = {
454454
session: {
455+
get: async () => ({ data: { directory: "/project" } }),
455456
create: async () => ({ data: { id: "ses_sync_error_test" } }),
456457
prompt: async () => {
457458
throw new Error("JSON Parse error: Unexpected EOF")
@@ -504,6 +505,7 @@ describe("sisyphus-task", () => {
504505

505506
const mockClient = {
506507
session: {
508+
get: async () => ({ data: { directory: "/project" } }),
507509
create: async () => ({ data: { id: "ses_sync_success" } }),
508510
prompt: async () => ({ data: {} }),
509511
messages: async () => ({
@@ -560,6 +562,7 @@ describe("sisyphus-task", () => {
560562

561563
const mockClient = {
562564
session: {
565+
get: async () => ({ data: { directory: "/project" } }),
563566
create: async () => ({ data: { id: "ses_agent_notfound" } }),
564567
prompt: async () => {
565568
throw new Error("Cannot read property 'name' of undefined agent.name")
@@ -610,6 +613,7 @@ describe("sisyphus-task", () => {
610613
const mockManager = { launch: async () => ({}) }
611614
const mockClient = {
612615
session: {
616+
get: async () => ({ data: { directory: "/project" } }),
613617
create: async () => ({ data: { id: "ses_sync_model" } }),
614618
prompt: async (input: any) => {
615619
promptBody = input.body

src/tools/sisyphus-task/tools.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -407,9 +407,9 @@ System notifies on completion. Use \`background_output\` with task_id="${task.id
407407
let syncSessionID: string | undefined
408408

409409
try {
410-
const parentSession = await client.session.get({
411-
path: { id: ctx.sessionID },
412-
}).catch(() => null)
410+
const parentSession = client.session.get
411+
? await client.session.get({ path: { id: ctx.sessionID } }).catch(() => null)
412+
: null
413413
const parentDirectory = parentSession?.data?.directory ?? directory
414414

415415
const createResult = await client.session.create({

0 commit comments

Comments
 (0)