openclaw - ✅(Solved) Fix [Bug]: Installer fails to install with "Cannot find name 'DEFAULT_CONTEXT_TOKENS'" in pi-embedded-runner [1 pull requests, 2 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#61567Fetched 2026-04-08 02:57:15
View on GitHub
Comments
2
Participants
2
Timeline
5
Reactions
0
Timeline (top)
commented ×2labeled ×2cross-referenced ×1

Running the current install.sh with --install-method git --no-onboarding fails to install while running tsc -p sconfig.plugin-sdk.dts.json with errors:

src/agents/pi-embedded-runner/model.ts:516:11 - error TS2304: Cannot find name 'DEFAULT_CONTEXT_TOKENS'".
src/agents/pi-embedded-runner/model.ts:521:11 - error TS2304: Cannot find name 'DEFAULT_CONTEXT_TOKENS'".
Found 2 errors in the same file, starting at: src/agents/pi-embedded-runner/model.ts:516
ELIFECYCLE Command failed with exit code 1

Error Message

src/agents/pi-embedded-runner/model.ts:516:11 - error TS2304: Cannot find name 'DEFAULT_CONTEXT_TOKENS'". src/agents/pi-embedded-runner/model.ts:521:11 - error TS2304: Cannot find name 'DEFAULT_CONTEXT_TOKENS'".

Root Cause

Running the current install.sh with --install-method git --no-onboarding fails to install while running tsc -p sconfig.plugin-sdk.dts.json with errors:

src/agents/pi-embedded-runner/model.ts:516:11 - error TS2304: Cannot find name 'DEFAULT_CONTEXT_TOKENS'".
src/agents/pi-embedded-runner/model.ts:521:11 - error TS2304: Cannot find name 'DEFAULT_CONTEXT_TOKENS'".
Found 2 errors in the same file, starting at: src/agents/pi-embedded-runner/model.ts:516
ELIFECYCLE Command failed with exit code 1

Fix Action

Fixed

PR fix notes

PR #61803: fix(agents): heartbeat always targets main session — prevent routing to active subagent sessions

Description (problem / solution / changelog)

What this fixes (plain English)

When background heartbeat checks ran while sub-agents were active, they could accidentally target a sub-agent's session instead of the main one — corrupting the sub-agent's task results by overwriting them with a heartbeat status. This fix ensures heartbeats always route to the main session.

Technical details

Root cause: resolveHeartbeatSession() had three code paths where a subagent session key could slip through:

  1. Via opts.sessionKey (forced session key)
  2. Via heartbeat.session config value
  3. Via post-canonicalization (where canonicalization transforms a key into a subagent format)

Fix: Added isSubagentSessionKey() guards to all three paths in resolveHeartbeatSession. Any subagent session key is now stripped at every entry point, falling back to mainSessionKey.

Files changed:

  • src/infra/heartbeat-runner.ts — import isSubagentSessionKey, add guards to all three resolution paths, simplify agent ID resolution
  • src/infra/heartbeat-runner.returns-default-unset.test.ts — parameterized regression test covering both entry vectors

Related

  • Fixes #58878
  • Recreated from clean branch (previous PR #61526 closed as dirty)
  • Parent initiative: #25592
  • Companion PRs: #61829, #61463, #61801

Test plan

  • 32/32 tests pass
  • Subagent session keys via opts.sessionKey are rejected -> falls back to mainSessionKey
  • Subagent session keys via heartbeat.session config are rejected -> falls back to mainSessionKey
  • Post-canonicalization subagent keys are rejected
  • Legitimate main session keys still route correctly

Changed files

  • src/infra/heartbeat-runner.returns-default-unset.test.ts (modified, +92/-0)
  • src/infra/heartbeat-runner.ts (modified, +25/-23)

Code Example

src/agents/pi-embedded-runner/model.ts:516:11 - error TS2304: Cannot find name 'DEFAULT_CONTEXT_TOKENS'".
src/agents/pi-embedded-runner/model.ts:521:11 - error TS2304: Cannot find name 'DEFAULT_CONTEXT_TOKENS'".
Found 2 errors in the same file, starting at: src/agents/pi-embedded-runner/model.ts:516
ELIFECYCLE Command failed with exit code 1

---
RAW_BUFFERClick to expand / collapse

Bug type

Regression (worked before, now fails)

Beta release blocker

No

Summary

Running the current install.sh with --install-method git --no-onboarding fails to install while running tsc -p sconfig.plugin-sdk.dts.json with errors:

src/agents/pi-embedded-runner/model.ts:516:11 - error TS2304: Cannot find name 'DEFAULT_CONTEXT_TOKENS'".
src/agents/pi-embedded-runner/model.ts:521:11 - error TS2304: Cannot find name 'DEFAULT_CONTEXT_TOKENS'".
Found 2 errors in the same file, starting at: src/agents/pi-embedded-runner/model.ts:516
ELIFECYCLE Command failed with exit code 1

Steps to reproduce

  1. Run curl -fsSL --proto '=https' --tlsv1.2 https://openclaw.ai/install.sh | bash -s -- --install-method git --git-dir ~/openclaw --no-onboard --verbose
  2. Fail

Expected behavior

Should install successfully

Actual behavior

Fails with errors mentioned in summary

OpenClaw version

main (reports as 2026.4.5)

Operating system

macOS Taho 26.2

Install method

git

Model

n/a

Provider / routing chain

n/a

Additional provider/model setup details

No response

Logs, screenshots, and evidence

Impact and severity

Severity: Blocks Install

Additional information

No response

extent analysis

TL;DR

The issue can likely be resolved by ensuring that the DEFAULT_CONTEXT_TOKENS variable is properly defined and imported in the model.ts file.

Guidance

  • Verify that DEFAULT_CONTEXT_TOKENS is defined in a file that is imported by model.ts, such as a constants or enums file.
  • Check the sconfig.plugin-sdk.dts.json file to ensure that it is correctly configured and includes the necessary type definitions.
  • Review the changes made to the codebase since the last successful installation to identify any potential regressions that may have introduced the error.
  • Consider running the installation script with additional verbosity or debugging flags to gather more information about the error.

Example

No code snippet is provided as the issue does not include sufficient information about the codebase or the specific changes made.

Notes

The issue may be related to a change in the type definitions or the codebase that is not properly handled by the installation script. Further investigation is needed to determine the root cause of the issue.

Recommendation

Apply workaround: Modify the model.ts file to properly import and define the DEFAULT_CONTEXT_TOKENS variable, or update the sconfig.plugin-sdk.dts.json file to include the necessary type definitions. This is recommended as the issue is likely related to a specific code change or configuration issue, and a workaround can help resolve the issue until a more permanent fix is available.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

Expected behavior

Should install successfully

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

openclaw - ✅(Solved) Fix [Bug]: Installer fails to install with "Cannot find name 'DEFAULT_CONTEXT_TOKENS'" in pi-embedded-runner [1 pull requests, 2 comments, 2 participants]