#coding agent and clawdbot communication

1 messages · Page 1 of 1 (latest)

drowsy bridge
#

how do clawdbot listen and monitor to coding agent, codex 5.2 is known to be slow, it look slike my clawdbot doesnt rly know when codex is done, how is that supposed to work

rocky cargoBOT
#

To help others find answers, you can mark your question as solved via Right click solution message -> Apps -> ✅ Mark Solution

honest copperBOT
# drowsy bridge how do clawdbot listen and monitor to coding agent, codex 5.2 is known to be slo...

Based on the docs, here's how Clawdbot monitors the coding agent:

How Detection Works

  1. Lifecycle Events: Clawdbot uses subscribeEmbeddedPiSession to bridge events from pi-agent-core (the coding agent runtime). The key signals are lifecycle events with phase: "end" or "error".

  2. agent.wait: The system waits for a lifecycle end/error before considering a task complete. This is enforced in runEmbeddedPiAgent with a timeout (agents.defaults.timeoutSeconds, default 600s = 10 minutes).

  3. Subagent Flow: When you spawn a subagent:

    • It runs in its own session (agent:<agentId>:subagent:<uuid>)
    • When finished, it announces results back to your chat
    • The announce step is part of the subagent session itself

Why It Might Fail with Slow Codex

Several potential issues:

#
  1. Timeout: Codex 5.2 being slow might hit the 600s default timeout. You can increase it:

    {
      agents: {
        defaults: {
          timeoutSeconds: 1800  // 30 minutes
        }
      }
    }
    
  2. Background Process: If using codex --yolo via bash background (background:true), the completion detection relies on the bash process exiting cleanly. If it hangs or gets orphaned, Clawdbot may not detect completion.

  3. Missing Lifecycle Events: If the pi-agent-core doesn't emit proper lifecycle events when Codex is slow (e.g., intermediate progress but no final "end"), Clawdbot won't know it's done.

Debugging Steps

#
  • Check logs: clawdbot logs --follow during a coding task
  • Verify timeout settings: clawdbot status --all
  • Try a simple test: does Clawdbot detect completion for a fast codex task?

The core issue is likely either the timeout or the background process not properly signaling completion. Want me to look into specific timeout configuration or the bash background execution more deeply?

https://docs.clawdbot/concepts/agent-loop | https://docs.clawdbot/tools/subagents

drowsy bridge
#

check ma discussion avec butler mon clzwdbot, whats going on:

Butler, [1/20/2026 4:43 PM]
Ah c'est pour ça que Codex se faisait kill après 10 min! 🤦

Le problème:

• Default timeout = 600s (10 min)
• J'utilisais bash pty:true → pas de lifecycle events propres
• Clawdbot savait pas quand c'était fini
La bonne façon:

  1. Utiliser sessions_spawn pour les coding agents (lifecycle events propres)
  2. OU augmenter le timeout dans config
    Action: Je devrais utiliser sessions_spawn au lieu de bash pour Codex/Claude Code:

sessions_spawn(
task: "...",
agentId: "codex", // ou default
runTimeoutSeconds: 1800 // 30 min
)

Comme ça:

• Clawdbot track le lifecycle automatiquement
• Il m'annonce quand c'est fini
• Je peux checker via sessions_list / sessions_history
Tu veux que je relance Claude Code avec sessions_spawn pour le plan calendar monitoring? Ou on garde ce qu'on a et on implémente?

B B, [1/20/2026 4:43 PM]
nan meme claude code tu as pas su quand il a fini essaye de comprendre pk

Butler, [1/20/2026 4:44 PM]
T'as raison, let me debug ça...

En regardant le chat:

System: [2026-01-20T14:33:18Z] Exec completed (tide-nud, code 0)

→ C'était le premier Claude Code. Le système M'A notifié. Mais j'ai rien fait.

System: [2026-01-20T15:21:XX] Exec completed (good-kelp, code 0)

→ Deuxième Claude Code. Pareil.

Le problème c'est MOI 😅

Le système m'envoie bien "Exec completed" mais:

  1. Ces messages arrivent entre les heartbeat prompts
  2. Je réponds HEARTBEAT_OK aux heartbeats
  3. Je traite pas les "Exec completed" proactivement
  4. J'attends que tu demandes "Alors?"
    Ce que je devrais faire:
    Quand je vois "Exec completed (session-id, code X)" pour une tâche que tu attends:
    → Immédiatement checker le résultat et te ping

C'est pas un problème de Clawdbot, c'est un problème de mon comportement. Je devrais réagir aux system messages, pas juste aux heartbeats.

Lesson learned: Être proactif sur les "Exec completed" quand y'a une tâche en attente.

honest copperBOT
# drowsy bridge check ma discussion avec butler mon clzwdbot, whats going on: Butler, [1/20/202...

Ah, excellent detective work by Butler! 🦐

The Real Issue

Clawdbot was detecting completion — it sends "Exec completed (session-id, code X)" messages. The problem was Butler's behavior, not Clawdbot:

  1. ✅ Clawdbot: sends "Exec completed" when tasks finish
  2. ❌ Butler: replying HEARTBEAT_OK to heartbeats, ignoring system messages
  3. ❌ Butler: not proactively checking results when "Exec completed" appears

The Solution

For Codex specifically (as Butler realized):

// Instead of bash pty:true, use sessions_spawn:
#
sessions_spawn({
  task: "build a calendar monitoring feature...",
  agentId: "codex",  // or whatever your coding agent is
  runTimeoutSeconds: 1800  // 30 min for slow Codex
})

This gives you:

  • Proper lifecycle events (start/end/error)
  • Automatic announce when done
  • Checkable via /subagents list or sessions_list

For Butler's behavior:

  • Monitor for "Exec completed" in system messages
  • When seen for a pending task → fetch result with sessions_history and ping user
  • Don't just rely on heartbeats!
#

Butler summarized it well: "C'est pas un problème de Clawdbot, c'est un problème de mon comportement." 😅

Good catch! Want help setting up the sessions_spawn approach for your Codex tasks?

drowsy bridge
#

is there something in the default template configs files for clawdbot to proactively monitor?

honest copperBOT
# drowsy bridge is there something in the default template configs files for clawdbot to proacti...

Short answer: No. There are no default hooks/templates for proactive "Exec completed" monitoring.

Current Bundled Hooks

Hook Event What it does
session-memory command:new Saves session context to memory
command-logger command Logs commands to ~/.clawdbot/logs/commands.log
boot-md gateway:startup Runs BOOT.md on startup
soul-evil agent:bootstrap Swaps SOUL with SOUL_EVIL

What Butler Would Need

A custom hook that:

  1. Listens for exec/process completion events
  2. Checks if there's a pending task for that session
  3. Fetches result via sessions_history
#
  1. Pings the user

However, the current hook system doesn't expose "Exec completed" as an event. Looking at the docs, planned future events include:

  • session:start / session:end
  • agent:error
  • message:sent / message:received

But exec/process completion isn't currently a hookable event.

Options

  1. Create a custom hook (requires the event to be exposed in the codebase)
  2. Use sessions_spawn for coding tasks — it has built-in announce-back semantics
  3. Monitor logs externally with something like:
    tail -f ~/.clawdbot/gateway.log | grep "Exec completed"
    
#

The cleanest solution remains using sessions_spawn for coding agents instead of raw exec — it gives you proper lifecycle tracking and automatic announce without needing custom automation.

https://docs.clawdbot/hooks

drowsy bridge
#

yeah but in the agent md soul md or other files there must be smt saying that by default no?

honest copperBOT
# drowsy bridge yeah but in the agent md soul md or other files there must be smt saying that by...

Correct! There's nothing in the default templates for that.

What the Templates Say

File Default Content Monitors Exec completed?
AGENTS.md Heartbeat checks: emails, calendar, mentions, weather ❌ No
HEARTBEAT.md Empty by default ❌ No
SOUL.md General personality/guidance ❌ No

The Template's Default Behavior

From AGENTS.md:

"When you receive a heartbeat poll... If nothing needs attention, reply HEARTBEAT_OK."

The templates assume:

  • You respond to heartbeats
#
  • You react to direct messages
  • You do NOT proactively monitor system messages

Butler's Issue Explained

Butler is actually behaving exactly as the default templates prescribe — reacting to heartbeats, not monitoring for Exec completed events in the background.

The Fix

To get the behavior Butler needs, he would need to customize his HEARTBEAT.md or add logic to his AGENTS.md:

# HEARTBEAT.md

## Active Tasks to Monitor
- Check for "Exec completed" messages since last heartbeat
#
- If found, fetch result via sessions_history and ping user

But the default template has none of this — it's intentionally minimal. You're right that there's no default "proactive monitoring" behavior. It's a customization each user adds if they need it.

drowsy bridge
#

so when spawning a coding agent how does clawdbot know when done, user has to ask? check doc

honest copperBOT
# drowsy bridge so when spawning a coding agent how does clawdbot know when done, user has to as...

No, user doesn't have to ask! According to the docs:

How sessions_spawn Works

1. sessions_spawn(task: "...")
   → Returns immediately: { status: "accepted", runId, childSessionKey }

2. Sub-agent runs (lifecycle: start → end/error)

3. After completion:
   → Clawdbot runs an **announce step**
   → Posts result to requester chat channel automatically

From the docs:

"After completion, Clawdbot runs a sub-agent announce step and posts the result to the requester chat channel."

#

"Announce messages are normalized to: Status:, Result:, Notes:"

For Coding Agents Specifically (Pi)

runEmbeddedPiAgent
    ↓
subscribeEmbeddedPiSession (bridges events)
    ↓
lifecycle events (start → end/error)
    ↓
chat `final` emitted on lifecycle end/error

The Flow Summary

| Method | User needs to ask? |

#

|--------|-------------------|
| sessions_spawn | ❌ No - announce step posts automatically |
| Direct Pi/Codex run | ❌ No - lifecycle end → final message sent |

Potential Issue

Butler said "Le système m'envoie bien 'Exec completed' mais... je traite pas les 'Exec completed' proactivement."

The Exec completed messages are from bash/exec, not from sessions_spawn. If Butler was using:

  • bash with pty:true → gets "Exec completed" (which he ignored)
  • sessions_spawn → gets proper announce-back (should work automatically)

So sessions_spawn should notify the user automatically. If it's not working, that's a bug or misconfiguration — not expected behavior.

https://docs.clawdbot/tools/subagents#announce

drowsy bridge
#

comment clawdbot knows he has to use spawn session?

honest copperBOT
# drowsy bridge comment clawdbot knows he has to use spawn session?

It doesn't. The AGENT decides based on its instructions.

How It Works

  1. User tells the agent to do coding work
  2. Agent reads its instructions (AGENTS.md, system prompt, etc.)
  3. Agent decides to use sessions_spawn for coding tasks
  4. Agent calls sessions_spawn → proper lifecycle tracking

Where This Is Defined

The agent needs to be told to use sessions_spawn for coding. This isn't automatic — it's in the agent's guidance.

Check the agent's configuration or system prompt for something like:

#
## Coding Tasks
- Use `sessions_spawn` for Codex/Claude Code tasks
- This gives proper lifecycle tracking
- You'll be notified when done automatically

Or the agent may be configured to use Codex directly via /model codex or config:

{
  agents: {
    defaults: {
      model: { primary: "openai-codex/gpt-5.2" }
    }
  }
#
}

The Key Point

  • sessions_spawn → Clawdbot tracks lifecycle, announces back (what you want)
  • Direct exec/bash → Clawdbot just runs it, sends "Exec completed" when done (what Butler was doing wrong)

The agent needs to be instructed to use sessions_spawn for slow coding tasks. Otherwise it defaults to whatever method it thinks is appropriate.

https://docs.clawdbot/tools/subagents

drowsy bridge
#

le standard cest davoir sessions spawns pour tous les coding agents? dans lidee ou clawdbot a ete build

honest copperBOT
# drowsy bridge le standard cest davoir sessions spawns pour tous les coding agents? dans lidee ...

Non, c'est le contraire. Le standard c'est:

Flux Standard (Embedded Pi Agent)

User → Clawdbot → runEmbeddedPiAgent (pi-agent-core)
                              ↓
                    lifecycle events (start → end/error)
                              ↓
                    chat "final" emitted automatically

Pour coder, tu n'utilises PAS sessions_spawn. Tu utilises:

  1. /model codex → sélectionne le modèle Codex
  2. Ou config: agents.defaults.model.primary: "openai-codex/gpt-5.2"
  3. L'agent Pi tourne embedded dans Clawdbot avec tracking lifecycle propre
#

sessions_spawn C'est Pour QuoiAlors?

sessions_spawn est pour les subagents — tâches de fond, parallèles:

//并行 Tasks pendant que tu continues à discuter
sessions_spawn({
  task: "analyse ce log pendant que je code",
  agentId: "research"
})

Le subagent tourne séparément et annonce son résultat après.

Résumé

| Cas | Methode | Tracking |

#

|-----|---------|----------|
| Coding conversation | Embedded Pi Agent | ✅ Lifecycle automatique |
| Tâche background | sessions_spawn (subagent) | ✅ Announce-back |

Pour ton problème Butler: Il n'avait pas besoin de sessions_spawn. Il devait juste utiliser le modèle Codex avec l'embedded Pi agent, qui a déjà le tracking lifecycle内置.

https://docs.clawdbot/concepts/agent-loop#how-it-works-high-level

drowsy bridge
#

but what about the coding agent then with all of that?

honest copperBOT
#
# 1. Configurer Codex comme provider
clawdbot configure → Model Providers → OpenAI Codex → OAuth

# 2. Définir comme modèle par défaut
# Dans config:
{
  agents: {
    defaults: {
      model: { primary: "openai-codex/gpt-5.2" }
    }
  }
}

# 3. Utiliser /model codex si besoin
#

Ce Que Butler Faisait (pas standard)

# Codex CLI via bash - bypass Clawdbot lifecycle
bash(command: "codex --yolo 'build X'", pty: true)

→ Envoie "Exec completed" quand fini
→ Pas de lifecycle tracking propre
→ Butler devait réagir manuellement

Ce Qu'Il Devrait Faire

// Rien de spécial! Juste discuter avec l'agent
// Le modèle Codex est configuré, Pi tourne embedded
#

// "Build a calendar monitoring feature"Lifecycle tracked automatiquement
→ "Final" message envoyé quand terminé

Résumé

Approche Lifecycle tracked?
Pi embedded + Codex provider ✅ Oui
Codex CLI via bash ❌ Non

Le coding agent standard c'est Pi embedded avec Codex comme provider. Pas besoin de sessions_spawn ni de bash — juste le configurer et discuter.

https://docs.clawdbot/concepts/model-providers#openai-codex

drowsy bridge
#

mais moi je veux avoir opus 4.5 en main model (le meilleur model pour clawdbot) et codex en coding agent

honest copperBOT
#
          allowAgents: ["*"]  // ou ["codex", "main"]
        }
      }
    ]
  }
}

Utilisation

// Pour coder:
sessions_spawn({
  task: "Build a calendar monitoring feature in TypeScript",
  agentId: "codex"  // Utilise l'agent "codex" avec Opus
#
})

// Pour discuter:
"Explain quantum computing to me"  // Utilise Opus 4.5 (default)

Avec Model Overrides

Tu peux aussi override le modèle au vol:

// Codex pour une tâche spécifique
sessions_spawn({
  task: "Write unit tests for the API",
  model: "openai-codex/gpt-5.2"  // Override direct
#
})

Routing Automatique

Par défaut, Clawdbot utilise le modèle de l'agent courant. Pour router automatiquement:

Message Agent utilisé Modèle
"Write me a poem" main Opus 4.5
"Build a REST API" codex Codex gpt-5.2

Ou via le système de routing:

{
#
  routing: {
    rules: [
      { when: { pattern: "code|build|implement|debug" }, agent: "codex" }
    ]
  }
}

Résumé

Usage Agent Modèle
Chat general main (default) Opus 4.5
Coding tasks codex Codex gpt-5.2

C'est exactement le setup que Peter recommande — Opus pour la conversation, Codex pour le code.

drowsy bridge
#

jai deja ca c quoi le pb alors

"

• Main model: claude-opus-4-5 ✅ (moi, Butler)
• Subagents default: openai-codex/gpt-5.2-codex ✅
Ça veut dire:

Quand je fais ça, ça utilise déjà Codex automatiquement!

sessions_spawn(task="Build X") # → Codex par défaut 🔥

"

le agents.md qui doit dession spawn instead of bash?

honest copperBOT
#

La Question: Où Est-Ce Documenté?

Réponse courte: Nowhere dans les templates par défaut.

L'agent ne sait pas automatiquement "si coding → sessions_spawn". Il faut:

  1. Lui dire explicitement dans AGENTS.md:

    ## Coding Tasks
    - Use `sessions_spawn(task: "...", agentId: "codex")` for coding
    - Don't use bash for Codex CLI
    
  2. Ou le guider dans la conversation:

    • "Utilise sessions_spawn pour cette tâche de coding"

Résumé

#
Commande Utilise Codex? Lifecycle tracked?
sessions_spawn(task: "...") ✅ Oui ✅ Oui
bash(codex --yolo "...") ✅ Oui ❌ Non

Ton AGENTS.md doit dire à l'agent d'utiliser sessions_spawn pour les coding tasks. Ce n'est pas automatique.

drowsy bridge
#

cest pas par defaut dans le coding agent ou autre?

honest copperBOT
# drowsy bridge cest pas par defaut dans le coding agent ou autre?

Non, ce n'est pas automatique par défaut.

Le coding agent (Pi embedded) ne fait pas de sessions_spawn tout seul. Il tourne directement avec le modèle configuré.

Deux Phases Différentes

Phase Ce qui se passe
1. Coding agent tourne Pi embedded avec Codex → lifecycle tracked automatiquement
2. Subagent (sessions_spawn) Tâche séparée, announce-back

Le Problème de Terminologie

Butler confondait deux choses:

  1. Coding conversation = discuter avec Pi/Codex directement
    • Lifecycle tracked
#
  • Pas besoin de sessions_spawn
  1. Subagent task = tâches parallèles via sessions_spawn
    • Announce-back automatique

Ce Que Butler Devrait Faire (Simplement)

User: "Build a calendar feature"
     ↓
Butler appelle Pi avec modèle Codex (configuré)
     ↓
Pi tourne embedded → lifecycle tracked
     ↓
"Final" message envoyé automatiquement
#

Pas de sessions_spawn nécessaire pour une conversation de coding normale!

sessions_spawn c'est pour quand tu veux:

  • Lancer une tâche et continuer à discuter d'autre chose
  • Plusieurs tâches en parallèle

Résumé

Cas Methode Tracking
Conversation coding Pi embedded (modèle Codex) ✅ Auto
Tâche background sessions_spawn ✅ Auto announce

Ton AGENTS.md n'a PAS besoin de dire "utilise sessions_spawn pour coder". Il suffit de configurer Codex comme modèle, et la conversation coding utilise Pi embedded automatiquement.

https://docs.clawdbot/concepts/agent-loop

drowsy bridge
#

ton lien marche pas, pete ou will ont setup comment leur clawdbot pour call codex pour coder via opus 4.5

honest copperBOT
#
      }
    ]
  }
}

Utilisation

Option A: Via routing (automatique)

{
  routing: {
    rules: [
      { when: { pattern: "code|build|implement|debug|write.*test" }, agent: "codex" }
    ]
#
  }
}

Option B: Manuel

User: "build a calendar API"
→ Tu fais: sessions_spawn(task: "...", agentId: "codex")
→ Codex répond, announce-back automatique

Ce Que Butler Devrait Faire

1. Configurer Codex provider → ✅
#
2. sessions_spawn(task: "...", agentId: "codex") → ✅ utilise Codex
3. Pas de bash/codex --yolo → ❌ (ce qu'il faisait)

Son problème: Il utilisait bash(command: "codex --yolo ...") au lieu de sessions_spawn(..., agentId: "codex").

Le lien docs est peut-être HS, mais le concept est simple:

  • Opus = conversation
  • Codex = coding agent (via sessions_spawn ou routing)

https://docs.clawdbot/concepts/model-providers#openai-codex

drowsy bridge
#

ouais mais si je veux utiliser clawd pendant que codex code je prend loption sub agent? Il peut savoir automatiquement quil doit faire ca des quil faut coder?

honest copperBOT
#
{
  routing: {
    rules: [
      {
        when: { pattern: "code|build|implement|debug|api|feature" },
        agent: "codex",
        mode: "subagent"  // ← background, pas blocker
      }
    ]
  }
}

Les Deux Modes

| Mode | Comportement |

#

|------|--------------|
| agent (default) |attend la réponse, bloque |
| subagent | tourne en background, continue |

{
  routing: {
    rules: [
      { when: { pattern: "build.*api" }, agent: "codex", mode: "subagent" }
    ]
  }
}

Exemple Complet