Commit Graph

183 Commits

Author SHA1 Message Date
Peter Steinberger
a700f9896d feat: telegram draft streaming 2026-01-07 11:08:32 +01:00
Tim Krase
e58e13708d Agents: add weekday to user time 2026-01-07 11:02:39 +01:00
Peter Steinberger
0914517ee3 feat(sandbox): add workspace access mode 2026-01-07 09:33:38 +00:00
Peter Steinberger
50dec39d13 fix: honor sandboxed built-in tools 2026-01-07 06:12:56 +00:00
Peter Steinberger
03928106c7 fix: order reasoning before reply text 2026-01-07 07:05:07 +01:00
Peter Steinberger
75c66acfd8 feat: update subagent announce + archive 2026-01-07 06:53:01 +01:00
Peter Steinberger
1673a221f8 feat: add /reasoning reasoning visibility 2026-01-07 06:17:31 +01:00
Erik
cd4e2023ab fix(agent): capture compaction retry AbortError for model fallback
Wrap waitForCompactionRetry() in try/catch to capture AbortError
that was escaping and bypassing the model fallback mechanism.

When a timeout fires, session.abort() causes both session.prompt()
and waitForCompactionRetry() to throw AbortError. Previously only
the prompt error was captured, allowing the compaction error to
escape to model-fallback.ts where it was immediately re-thrown
(line 199: isAbortError check), bypassing fallback model attempts.

Fixes #313
2026-01-07 01:44:37 +01:00
Peter Steinberger
19c95d0ff7 fix(auth): serialize profile stats updates 2026-01-07 01:06:51 +01:00
Peter Steinberger
96d72ff91e fix(auth): lock auth profile updates 2026-01-07 01:00:47 +01:00
Muhammed Mukhthar CM
eb5f758f6b fix(auth): improve multi-account round-robin rotation and 429 handling
This commit fixes several issues with multi-account OAuth rotation that
were causing slow responses and inefficient account cycling.

## Changes

### 1. Fix usageStats race condition (auth-profiles.ts)

The `markAuthProfileUsed`, `markAuthProfileCooldown`, `markAuthProfileGood`,
and `clearAuthProfileCooldown` functions were using a stale in-memory store
passed as a parameter. Long-running sessions would overwrite usageStats
updates from concurrent sessions when saving.

**Fix:** Re-read the store from disk before each update to get fresh
usageStats from other sessions, then merge the update.

### 2. Capture AbortError from waitForCompactionRetry (pi-embedded-runner.ts)

When a request timed out, `session.abort()` was called which throws an
`AbortError`. The code structure was:

```javascript
try {
  await session.prompt(params.prompt);
} catch (err) {
  promptError = err;  // Catches AbortError here
}
await waitForCompactionRetry();  // But THIS also throws AbortError!
```

The second `AbortError` from `waitForCompactionRetry()` escaped and
bypassed the rotation/fallback logic entirely.

**Fix:** Wrap `waitForCompactionRetry()` in its own try/catch to capture
the error as `promptError`, enabling proper timeout handling.

Root cause analysis and fix proposed by @erikpr1994 in #313.

Fixes #313

### 3. Fail fast on 429 rate limits (pi-ai patch)

The pi-ai library was retrying 429 errors up to 3 times with exponential
backoff before throwing. This meant a rate-limited account would waste
30+ seconds retrying before our rotation code could try the next account.

**Fix:** Patch google-gemini-cli.js to:
- Throw immediately on first 429 (no retries)
- Not catch and retry 429 errors in the network error handler

This allows the caller to rotate to the next account instantly on rate limit.

Note: We submitted this fix upstream (https://github.com/badlogic/pi-mono/pull/504)
but it was closed without merging. Keeping as a local patch for now.

## Testing

With 6 Antigravity accounts configured:
- Accounts rotate properly based on lastUsed (round-robin)
- 429s trigger immediate rotation to next account
- usageStats persist correctly across concurrent sessions
- Cooldown tracking works as expected

## Before/After

**Before:** Multiple 429 retries on same account, 30-90s delays
**After:** Instant rotation on 429, responses in seconds
2026-01-07 00:56:32 +01:00
Peter Steinberger
e0efcda77f fix(commands): wire /stop across chat commands 2026-01-06 23:11:57 +00:00
Nacho Iacovino
0df7c3addf feat(telegram): add /stop command to abort running agent
Adds a /stop command that:
- Can interrupt a running agent session mid-execution
- Works in both DMs and group chats (including forum topics)
- Uses grammy's bot.command() to run before the main message handler
- Returns status: stopped, stop requested, or nothing running

Also fixes session key lookup in pi-embedded-runner to use sessionKey
instead of sessionId, ensuring /stop finds the correct active run.
2026-01-06 23:11:57 +00:00
Peter Steinberger
7aa7fa79d0 feat: update heartbeat defaults 2026-01-06 21:54:42 +00:00
Emanuel Stadler
fb17a32283 feat: enhance error handling for socket connection errors
- Added `isError` property to `EmbeddedPiRunResult` and reply items to indicate error states.
- Updated error handling in `runReplyAgent` to provide more informative messages for specific socket connection errors.
2026-01-06 22:19:37 +01:00
Peter Steinberger
2f24ea492b fix: restore Anthropic token accounting 2026-01-06 18:52:01 +00:00
Peter Steinberger
dbfa316d19 feat: multi-agent routing + multi-account providers 2026-01-06 18:33:37 +00:00
Peter Steinberger
aa16b679ad fix: improve auth profile failover 2026-01-06 07:18:06 +01:00
Muhammed Mukhthar CM
18c7795ee0 feat: treat timeout as rate limit for profile rotation
Antigravity rate limits cause requests to hang indefinitely rather than
returning 429 errors. This change detects timeouts and treats them as
potential rate limits:

- Added timedOut flag to track timeout-triggered aborts
- Timeout now triggers profile cooldown + rotation
- Logs: "Profile X timed out (possible rate limit). Trying next account..."

This ensures automatic failover when Antigravity hangs due to rate limiting.
2026-01-06 05:20:01 +00:00
Muhammed Mukhthar CM
ce6c7737c1 feat: add round-robin rotation and cooldown for auth profiles
Adds usage tracking to auth profiles for automatic rotation:

- ProfileUsageStats type with lastUsed, cooldownUntil, errorCount
- markAuthProfileUsed(): tracks successful usage, resets errors
- markAuthProfileCooldown(): applies exponential backoff (1/5/25/60min)
- isProfileInCooldown(): checks if profile should be skipped
- orderProfilesByMode(): now sorts by lastUsed (oldest first)

On auth/rate-limit failures, profiles are marked for cooldown before
rotation. On success, usage is recorded for round-robin ordering.

This enables automatic load distribution across multiple accounts
(e.g., Antigravity 5-hour rate limit windows).
2026-01-06 05:17:59 +00:00
Peter Steinberger
77789cb9a8 fix: improve compaction queueing and oauth flows 2026-01-06 05:41:24 +01:00
Peter Steinberger
b6ac2d860d fix: resolve embedded api key lookup 2026-01-06 02:49:44 +01:00
Peter Steinberger
87f4efda8d fix: restore auth fallback ordering 2026-01-06 01:38:15 +00:00
Peter Steinberger
b56338171b feat: gate slash commands and add compact 2026-01-06 02:23:55 +01:00
Peter Steinberger
e73573eaea fix: clean model config typing 2026-01-06 01:08:36 +00:00
Peter Steinberger
b04c838c15 feat!: redesign model config + auth profiles 2026-01-06 00:56:58 +00:00
Peter Steinberger
20e00eb89b fix: normalize unknown prompt errors 2026-01-05 23:05:57 +00:00
Peter Steinberger
ac3dedaa1b feat: standardize timestamps to UTC 2026-01-05 23:03:59 +00:00
Peter Steinberger
f790f3f3ba
fix/heartbeat ok delivery filter (#246)
* cron: skip delivery for HEARTBEAT_OK responses

When an isolated cron job has deliver:true, skip message delivery if the
response is just HEARTBEAT_OK (or contains HEARTBEAT_OK at edges with
short remaining content <= 30 chars). This allows cron jobs to silently
ack when nothing to report but still deliver actual content when there
is something meaningful to say.

Media is still delivered even if text is HEARTBEAT_OK, since the
presence of media indicates there's something to share.

* fix(heartbeat): make ack padding configurable

* chore(deps): update to latest

---------

Co-authored-by: Josh Lehman <josh@martian.engineering>
2026-01-05 22:52:13 +00:00
CI
c627efce3e fix(model): retry with supported thinking level 2026-01-05 21:34:08 +00:00
CI
5622dfe86b fix: retry model fallback on rate limits 2026-01-05 21:34:08 +00:00
Peter Steinberger
86ad703f53 refactor(agent): extract block chunker + tool adapter 2026-01-05 18:05:40 +00:00
Peter Steinberger
7c89ce93b5 fix(agent): align tools + preserve indentation 2026-01-05 17:55:20 +00:00
Julian Engel
110e2255c4 fix: pass custom tools via customTools parameter to pi-coding-agent SDK
The SDK's tools parameter only accepts built-in tools (read, bash, edit, write).
Custom clawdbot tools (browser, canvas, nodes, cron, etc.) were being filtered
out, causing 'Tool not found' errors at runtime.

Split tools into built-in and custom, passing them via the correct parameters.
2026-01-05 17:00:06 +00:00
Peter Steinberger
724354b9f0 fix: make tool list dynamic in system prompt 2026-01-05 06:36:24 +00:00
Peter Steinberger
435edaf997 fix: OpenAI tool schema compatibility 2026-01-05 00:15:55 +01:00
Peter Steinberger
2ceceb8c25 style(ts): normalize type-only imports 2026-01-04 21:56:16 +01:00
Peter Steinberger
78998dba9e feat: add image model config + tool 2026-01-04 19:35:49 +01:00
Peter Steinberger
e005dcb8e7 fix(oauth): derive oauth.json from state dir 2026-01-04 19:08:13 +01:00
Peter Steinberger
246adaa119 chore: rename project to clawdbot 2026-01-04 14:38:51 +00:00
Peter Steinberger
fe0b3500cc feat: add elevated bash mode 2026-01-04 05:15:59 +00:00
Peter Steinberger
add1301a51 feat(sessions): add agent-to-agent post step 2026-01-04 03:04:55 +01:00
Peter Steinberger
8724c2aea8 fix: satisfy gate checks 2026-01-04 01:16:53 +01:00
Peter Steinberger
5862f95bd2 fix: lock main session deletion 2026-01-03 23:57:17 +00:00
Peter Steinberger
5493772910 fix: tolerate missing sandbox config in embedded runner 2026-01-03 21:30:40 +00:00
Peter Steinberger
d8a417f7ff feat: add sandbox browser support 2026-01-03 22:14:18 +01:00
Peter Steinberger
107dc1aa42 style(logging): organize embedded log imports 2026-01-03 21:09:44 +00:00
Peter Steinberger
3872f32419 fix(logging): quiet embedded run console logs 2026-01-03 20:57:39 +00:00
Peter Steinberger
7bad9f3fbd fix: drop embedded sandbox wiring 2026-01-03 20:16:53 +00:00
Peter Steinberger
16e3535ac0 refactor: remove bash pty mode 2026-01-03 20:15:10 +00:00
Peter Steinberger
a15cffb7de fix: stream tool summaries early and tool output 2026-01-03 21:04:40 +01:00
Shadow
ce92fac983
chore: formatting 2026-01-03 12:35:16 -06:00
Peter Steinberger
9f8eeceae7 feat: soften block streaming chunking 2026-01-03 16:48:26 +01:00
Peter Steinberger
72f8148080 fix: clean up embedded lint 2026-01-03 15:09:07 +00:00
Peter Steinberger
9a9b429f74 fix: elevate embedded run logs to info 2026-01-03 15:03:03 +00:00
Peter Steinberger
733e86516e fix: address runtime warnings in build 2026-01-03 15:01:38 +00:00
Peter Steinberger
1a00175eb7 chore: fix lint formatting 2026-01-03 14:57:49 +00:00
Peter Steinberger
48731f494b fix: add embedded run logs and typing ttl 2026-01-03 14:09:19 +00:00
Peter Steinberger
772ada4308 fix: refine tool summaries and scope discord tool 2026-01-03 12:33:42 +01:00
Peter Steinberger
2d28fa34f5 feat: make block streaming break configurable 2026-01-03 01:49:27 +01:00
Peter Steinberger
9616f4b2b1 feat: stream reply blocks immediately 2026-01-03 00:28:33 +01:00
Peter Steinberger
fc54e905c0 chore: upgrade pi-mono deps to 0.31.1 2026-01-02 23:37:08 +01:00
Peter Steinberger
2c92ccd66e feat: add reply tags and replyToMode 2026-01-02 23:18:41 +01:00
Peter Steinberger
956db9c182 fix: keep pi-ai tool types for published sdk 2026-01-01 17:02:02 +00:00
Peter Steinberger
f0f5acfa42 fix: update pi-agent-core integration 2026-01-01 16:46:40 +00:00
Peter Steinberger
7e380bb6f8 fix: enable lmstudio responses and drop think tags 2025-12-27 00:28:52 +00:00
Peter Steinberger
8dda07a1e9 feat(queue): add queue modes and discord gating 2025-12-26 13:35:44 +01:00
Peter Steinberger
82ced33747 fix: align pi model discovery with auth storage 2025-12-26 11:49:13 +01:00
Peter Steinberger
d28265cfbe fix: handle embedded agent overflow 2025-12-26 10:20:21 +01:00
Peter Steinberger
655fa5b8e0 style: fix pi embedded runner lint 2025-12-25 23:58:37 +00:00
Peter Steinberger
198f8ea700 fix(agent): serialize runs per session 2025-12-25 23:50:52 +01:00
Peter Steinberger
aafcd569b1 feat: line-based process logs 2025-12-25 18:03:57 +00:00
Peter Steinberger
3fcdd6c9d7 feat: enforce final tag parsing for embedded PI 2025-12-24 00:52:33 +00:00
Peter Steinberger
b05981ef27 fix: add reasoning tag hint for local providers 2025-12-23 14:34:56 +00:00
Peter Steinberger
f667d56701 fix: tag owner numbers in system prompt 2025-12-23 14:19:41 +00:00
Peter Steinberger
f70fd30cd3 chore: include runtime info in system prompt 2025-12-23 14:05:43 +00:00
Peter Steinberger
cba12a1abd fix: inject group activation in system prompt 2025-12-23 13:32:07 +00:00
Peter Steinberger
a5f4332f21 style: apply biome formatting 2025-12-23 02:49:49 +01:00
Peter Steinberger
082c872469 feat: support custom model providers 2025-12-23 02:48:48 +01:00
Peter Steinberger
918cbdcf03 refactor: lint cleanups and helpers 2025-12-23 00:28:55 +00:00
Peter Steinberger
e403f8b620 style(pi): sort imports 2025-12-22 22:55:27 +00:00
Peter Steinberger
4ca6591045 refactor: move OAuth storage and drop legacy sessions 2025-12-22 21:02:48 +00:00
Peter Steinberger
9717f2d374 fix: bump pi deps and fix lint 2025-12-22 20:45:38 +00:00