Skip to content
Agentmart
Submit a tool

core

How to work in a recurse session - the ipython tool, persistent state, bash handles, child agents, messages, and skills.

Skill by StevenJPx2

IndexedMIT
Write a review

Chalk Labs

Need help deploying core?

Chalk Labs sets up agents like this inside real teams: connected to your tools, tested on your data, with a human in the loop where it matters.

Book a call

Install

Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.

npx agentmarket install skill/stevenjpx2-core

Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.

Get the weekly diff

The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.

We use your email only for this newsletter. Privacy

About

How to work in a recurse session - the ipython tool, persistent state, bash handles, child agents, messages, and skills.

No reviews yet. Installed it? Reviews come from verified installers only. How reviews work

Permissions

What this skill can do and what it asks for, from its SKILL.md. Checked Oct 25, 2026.

Tools
No tools found
Secrets
None asked for
Install scripts
None found

Network hosts it talks to 1

  • codeload.github.com · found in install command

Files it touches

  • ~/.claude/skills/core

What's inside

Skill name
core
Description
How to work in a recurse session - the ipython tool, persistent state, bash handles, child agents, messages, and skills.
License
MIT
Instructions
124 lines in SKILL.md · view on GitHub

Files (2)

  • SKILL.md
  • python-api.md · references/

SKILL.md (first lines)

# Working in a recurse session

You have one tool, `ipython`. Each call runs a cell in a **persistent Python
kernel** (Python ≥ 3.11) in the session's working directory. Everything else —
files, shell commands, skills, child agents — is reached from Python.

Full signatures: `print(read_skill("core", "references/python-api.md"))`.

## Cells

- State persists across calls, turns, and host compaction: variables,
  imports, functions, parsed data, and handles are still there next turn.
  It is lost only on `kernel.restart` or a daemon restart.
- Top-level `await` works. Do not call `asyncio.run()`.
- The cell returns captured stdout/stderr (≤ 64 KiB each, tail kept) and the
  `repr` of the last expression (≤ 16 KiB). Print summaries, not whole files.
- Errors come back as a traceback with frames named `<cell N>`.
- Long cells are interrupted at the daemon's timeout (default 600 s); state
  survives. Background asyncio tasks keep running between cells; their output
  appears at the start of the next cell's output.

## Files

Use plain Python. Keep results in variables instead of re-reading.

```python
from pathlib import Path
src = Path("src/auth.py").read_text()
Path("src/auth.py").write_text(src.replace("md5(", "sha256("))
hits = [p for p in Path(".").rglob("*.py") if "TODO" in p.read_text(errors="ignore")]
```

## Shell: `bash()`

Each `bash(cmd)` is its own process in its own process group, using the
kernel's current `os.getcwd()` and `os.environ` (so `os.chdir` and
`os.environ[...] = ...` apply to later commands).

```python
r = await bash("npm run check")     # BashResult(output, exit_code, stdout, stderr)
print(r.exit_code, r.output[-2000:])
```

For anything slow (test suites, builds, servers), keep the live handle and
**end your turn** instead of blocking:

```python
tests = bash("npm test")
tests.pid                            # then stop and reply; you will be woken
```

When an unread handle's process group finishes, you receive
`[recurse] Background command finished: pid …, exit … (…)`. Then inspect it:
`tests.poll()`, `tests.tail(60)`, `tests.output()`, or `await tests`.
Reading a finished handle from a cell cancels a notice that is still queued.
`await bash(...)` never produces a notice. `h.kill()` stops the group.
`bash(cmd, timeout=30)` kills it after 30 s. Background jobs (`cmd &`) keep
the handle alive until the whole group exits.

## Child agents

`rlm.spawn` creates a native child session of the host with its own context
and its own kernel. It returns at admission with a handle — never the answer.

```python
api = await rlm.spawn("Review the public API in src/api for breaking changes. "
                      "Reply with a bullet list of findings.", name="api-reviewer")
tests = await rlm.spawn("Find untested branches in src/auth.", name="test-gaps")
```

Rules:

1. Give each child a complete, self-contained task: goal, paths, constraints,
   and what to send back. Children see nothing of your context.
2. Spawn independent children in separate calls, then **end the turn**. Do not
   poll or sleep waiting for them.
3. Results arrive only as `agent_message` replies (they wake you with
   `[recurse] message from child <name> …`) or as files the child writes. For
   large results, ask the child to write a file and message you its path.
4. Names match `^[a-z0-9][a-z0-9-]{0,62}$` and are unique among your live
   children. At most 16 live children.
5. Follow up with a retained child:
   `await agent_message.send("Also check pagination.", receiver_role="child", receiver_name="api-reviewer")`
6. Inspect and clean up: `for c in await rlm.list_subagents(): print(c.session_name, c.status, c.active_session_id)`;
   `await rlm.delete_subagent(api)` when its context is no longer needed.

Status: `pending` (being created), `running`, `failed` (you get a message with
the reason), `deleted`.

### If you are a child

Your first prompt says so. Do the task, then reply:

```python
await agent_message.send("Found 2 issues:\n- …\n- …", receiver_role="parent")
```

Your final chat answer is not seen by the parent — only `agent_message` and
files are. Children cannot spawn children unless `rlm.max_depth > rlm.depth`.

## Skills

`skills()` lists skill metadata; `read_skill(name)` returns its `SKILL.md`
(`read_skill(name, "references/x.md")` for bundled files). Read a skill when a
task matches its description, then follow it. Python-backed skills are
preloaded under the skill name with `-` → `_` (`repo-map` → `repo_map`); call
them directly, and `await` them if the skill says they are async.

## Errors

Host bridge failures raise `rlm.RecurseError` subclasses with `.code`:
`rlm.UnsupportedHost` (this host cannot create children — e.g. MCP or CLI; do
the work yourself), `rlm.DepthExceeded`, `rlm.LimitExceeded`, `rlm.NotFound`,
`rlm.InvalidRequest`. Catch them and adapt; do not retry blindly.

## Trust model

The kernel runs your Python and shell commands with the user's operating-system
permissions, outside the host's per-tool permission prompts. It is not a

From StevenJPx2/recurse, MIT.

Signals

Stars
0
Forks
0
Open issues
0
Last commit (this folder)
Sep 23, 2026 (1 month ago)

From GitHub (fetched Oct 24, 2026).

Details

License
MIT
First seen
Oct 24, 2026
Last checked
Oct 24, 2026

More from StevenJPx2

Done for you

Rather not set it up yourself?

Chalk Labs scopes, builds and runs agents for your team: the task audit, the eval harness, the integrations and the weekly ops report. Fixed scope, priced before we start.

See how we build AI agents →Read the case studies

Chalk Labs is a two-founder AI and growth studio. We build AI agents, CRMs and MVPs for Web3 and AI companies, and have shipped 50+ product and token launches.

launches shipped
50+
launches shipped
media placements
500+
media placements
founders on every account
2
founders on every account

Press we've placed: Forbes · CoinDesk · Decrypt · Cointelegraph · The Block

Rahil Jain, Co-founder, Chalk Labs. Ex-Goldman Sachs engineer. You talk to the person who builds it.

Get core running in your business

Tell us what you want to automate. A founder replies within one working day with a plan, not a pitch deck.

Goes to the Chalk Labs founders, not the newsletter. Privacy

Need help deploying core?

CallGet help
Cite this page

core skill. Agent Mart. https://agentmart.dev/skills/stevenjpx2-core (last updated 2026-10-24)