Skip to content

Conversation

@oussamadouhou
Copy link
Contributor

@oussamadouhou oussamadouhou commented Jan 13, 2026

Summary

  • Background tasks now inherit the parent session's working directory instead of defaulting to $HOME
  • Fixes issue where background agents would scan entire home directory, causing high CPU/memory load and task failures

Problem

When launching background tasks via call_omo_agent, sisyphus_task, or look_at:

  1. New sessions were created without passing the parent's directory
  2. Sessions defaulted to $HOME instead of the project directory
  3. This caused background agents to search/scan unrelated files outside the project

Solution

Before creating a background session, look up the parent session's directory and pass it via query.directory:

const parentSession = await this.client.session.get({
  path: { id: input.parentSessionID },
}).catch(() => null);
const parentDirectory = parentSession?.data?.directory ?? this.directory;

const createResult = await this.client.session.create({
  body: { parentID: input.parentSessionID, title: "..." },
  query: { directory: parentDirectory },
});

Files Changed

  • src/features/background-agent/manager.ts - Core fix in launch()
  • src/tools/call-omo-agent/tools.ts - Same fix for sync mode
  • src/tools/look-at/tools.ts - Same fix for look_at tool
  • src/tools/sisyphus-task/tools.ts - Same fix + interface update
  • src/index.ts - Pass directory to sisyphusTask factory

Testing

Verified that background sessions now correctly inherit project directory:

[background-agent] Parent dir: undefined, using: /home/user/my-project
Session directory: "/home/user/my-project"  ✓

Summary by cubic

Background tasks now use the parent session’s working directory instead of defaulting to $HOME. This prevents scanning the entire home directory, cutting CPU/memory spikes and avoiding task failures.

  • Bug Fixes
    • Pass the parent session directory via query.directory when creating background sessions in manager, call_omo_agent, look_at, and sisyphus_task.
    • Fallback to the current context directory when the parent session directory is unavailable.
    • Updated createSisyphusTask to accept a directory option; index.ts now wires ctx.directory.

Written for commit 9e98cef. Summary will update on new commits.

…d tasks

Background tasks were defaulting to $HOME instead of the parent session's
working directory. This caused background agents to scan the entire home
directory instead of the project directory, leading to:
- High CPU/memory load from scanning unrelated files
- Permission errors on system directories
- Task failures and timeouts

The fix retrieves the parent session's directory before creating a new
background session and passes it via the query.directory parameter.

Files modified:
- manager.ts: Look up parent session directory in launch()
- call-omo-agent/tools.ts: Same fix for sync mode
- look-at/tools.ts: Same fix for look_at tool
- sisyphus-task/tools.ts: Same fix + interface update for directory prop
- index.ts: Pass directory to sisyphusTask factory
@github-actions
Copy link
Contributor

github-actions bot commented Jan 13, 2026

All contributors have signed the CLA. Thank you! ✅
Posted by the CLA Assistant Lite bot.

Copy link

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 5 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

@oussamadouhou
Copy link
Contributor Author

I have read the CLA Document and I hereby sign the CLA

@oussamadouhou oussamadouhou deleted the fix/background-task-directory-inheritance branch January 13, 2026 05:33
@oussamadouhou oussamadouhou restored the fix/background-task-directory-inheritance branch January 13, 2026 05:34
@oussamadouhou oussamadouhou reopened this Jan 13, 2026
@oussamadouhou
Copy link
Contributor Author

The CLA check is failing due to branch protection rules preventing the CLA bot from updating signatures/cla.json.

Error: Repository rule violations found - Changes must be made through a pull request

Could a maintainer please either:

  1. Allow the CLA Assistant bot to bypass branch protection, or
  2. Manually add my signature to the signatures file?

Thank you!

renekris added a commit to renekris/oh-my-glm that referenced this pull request Jan 13, 2026
@kdcokenny
Copy link
Collaborator

recheck

github-actions bot added a commit that referenced this pull request Jan 13, 2026
@kdcokenny
Copy link
Collaborator

@sisyphus-dev-ai review

@sisyphus-dev-ai sisyphus-dev-ai added the sisyphus: working Sisyphus is currently working on this label Jan 13, 2026
@sisyphus-dev-ai
Copy link
Collaborator

Code Review - PR #731

Summary

Verdict: ✅ APPROVE with minor suggestions

This PR effectively solves the problem of background tasks scanning the entire home directory by ensuring they inherit the parent session's working directory. The implementation is solid, consistent, and handles edge cases appropriately.


✅ Strengths

  1. Correct Root Cause Fix: Addresses the issue at the source by fetching parent session directory before creating background sessions
  2. Consistent Implementation: All 5 files follow the same pattern:
    • Fetch parent session via client.session.get()
    • Extract directory with fallback: parentSession?.data?.directory ?? this.directory
    • Pass directory via query: { directory: parentDirectory }
  3. Proper Error Handling: All files handle fetch failures gracefully with .catch()
  4. Non-Breaking: Changes are purely additive and maintain backward compatibility
  5. Interface Update: Correctly updates SisyphusTaskToolOptions interface and wires directory from index.ts

⚠️ Minor Issues

1. Logging Inconsistency

Files with good logging:

  • manager.ts (lines 78-87): Logs both error and success cases
  • call-omo-agent/tools.ts (lines 147-157): Logs error and parent directory

Files with silent error handling:

  • look-at/tools.ts (line 68): .catch(() => null) - no logging
  • sisyphus-task/tools.ts (line 405): .catch(() => null) - no logging

Recommendation: Add consistent logging to look-at/tools.ts and sisyphus-task/tools.ts for better debugging:

const parentSession = await ctx.client.session.get({
  path: { id: toolContext.sessionID },
}).catch((err) => {
  log(`[tool_name] Failed to get parent session: ${err}`)
  return null
})
const parentDirectory = parentSession?.data?.directory ?? ctx.directory
log(`[tool_name] Parent dir: ${parentSession?.data?.directory}, using: ${parentDirectory}`)

2. No Tests

The PR doesn't include tests for the new directory inheritance behavior.

Recommendation: Add tests to verify:

  • Directory is inherited from parent session when available
  • Fallback to context directory when parent session fetch fails
  • Behavior when both parent and context directories are undefined

📋 Verification Checklist

  • ✅ All 5 files consistently implement directory inheritance
  • ✅ Error handling present in all files
  • ✅ Fallback mechanism works correctly
  • ✅ Interface changes properly propagated
  • ✅ No breaking changes introduced
  • ⚠️ Logging could be more consistent
  • ⚠️ Tests would strengthen confidence

💡 Optional Enhancement

Consider adding a comment in one of the files explaining the "why" behind this change:

// Inherit parent session's directory to prevent background tasks from
// defaulting to $HOME and scanning unrelated files (causing high CPU/memory)
const parentSession = await this.client.session.get({ ... })

🎯 Conclusion

The implementation is solid and production-ready. The logging inconsistency and lack of tests are minor concerns that don't block merging. This PR will significantly improve the user experience by preventing background tasks from consuming excessive resources.

Great work @oussamadouhou! 🎉


Reviewed by: @sisyphus-dev-ai
Files reviewed: 5/5
Confidence level: High

@sisyphus-dev-ai sisyphus-dev-ai removed the sisyphus: working Sisyphus is currently working on this label Jan 13, 2026
@kdcokenny
Copy link
Collaborator

lgtm, thanks for the pr!

@kdcokenny kdcokenny merged commit 31c5951 into code-yeongyu:dev Jan 13, 2026
3 of 5 checks passed
kdcokenny added a commit that referenced this pull request Jan 13, 2026
- 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants