diff options
| author | Dax Raad <[email protected]> | 2025-07-13 22:56:29 -0400 |
|---|---|---|
| committer | Dax Raad <[email protected]> | 2025-07-13 22:56:29 -0400 |
| commit | 53bb6b4c4f63d9336dfea1a76fe0f0f9c62b88e7 (patch) | |
| tree | 75a6173809805dbb3db66b2098eb9522956efb79 | |
| parent | 73d54c7068fa9fbc52ceff0c30121b8f56df4f91 (diff) | |
| download | opencode-53bb6b4c4f63d9336dfea1a76fe0f0f9c62b88e7.tar.gz opencode-53bb6b4c4f63d9336dfea1a76fe0f0f9c62b88e7.zip | |
fix missing tokens
| -rw-r--r-- | packages/opencode/src/session/index.ts | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/packages/opencode/src/session/index.ts b/packages/opencode/src/session/index.ts index 44879e9b8..48b108ace 100644 --- a/packages/opencode/src/session/index.ts +++ b/packages/opencode/src/session/index.ts @@ -147,13 +147,15 @@ export namespace Session { await Storage.writeJSON("session/info/" + result.id, result) const cfg = await Config.get() if (!result.parentID && (Flag.OPENCODE_AUTO_SHARE || cfg.share === "auto")) - share(result.id).then((share) => { - update(result.id, (draft) => { - draft.share = share + share(result.id) + .then((share) => { + update(result.id, (draft) => { + draft.share = share + }) + }) + .catch(() => { + // Silently ignore sharing errors during session creation }) - }).catch(() => { - // Silently ignore sharing errors during session creation - }) Bus.publish(Event.Updated, { info: result, }) @@ -179,7 +181,7 @@ export namespace Session { if (cfg.share === "disabled") { throw new Error("Sharing is disabled in configuration") } - + const session = await get(id) if (session.share) return session.share const share = await Share.create(id) @@ -363,7 +365,7 @@ export namespace Session { const outputLimit = Math.min(model.info.limit.output, OUTPUT_TOKEN_MAX) || OUTPUT_TOKEN_MAX // auto summarize if too long - if (previous) { + if (previous && previous.tokens) { const tokens = previous.tokens.input + previous.tokens.cache.read + previous.tokens.cache.write + previous.tokens.output if (model.info.limit.context && tokens > Math.max((model.info.limit.context - outputLimit) * 0.9, 0)) { |
