Cloned repository to local directory.
SetupReviewed code for pruning logic.
UnderstandConfirmed comprehensive pruning implementation.
Verifyclone this repo to /tmp https://github.com/clawdbot/clawdbot. then analyze if they implemented tool result pruning or any form of history pruning in the code that uses pi-mono (coding-agent SDK)
The user wants me to:
Let me start by cloning the repo.
>cd /tmp && rm -rf clawdbot && git clone https://github.com/clawdbot/clawdbot.git 2>&1Cloning into 'clawdbot'...Repo cloned. Now let me explore the structure and find where they use the pi-mono SDK.
>cd /tmp/clawdbot && find . -type f -name "*.ts" -o -name "*.js" | head -50./ui/vite.config.ts
./ui/vitest.config.ts
./ui/src/ui/app-defaults.ts
./ui/src/ui/app-settings.ts
./ui/src/ui/navigation.test.ts
./ui/src/ui/uuid.ts
./ui/src/ui/types/chat-types.ts
./ui/src/ui/focus-mode.browser.test.ts
./ui/src/ui/uuid.test.ts
./ui/src/ui/app-render.ts
./ui/src/ui/chat/message-normalizer.ts
./ui/src/ui/chat/message-extract.test.ts
./ui/src/ui/chat/copy-as-markdown.ts
./ui/src/ui/chat/grouped-render.ts
./ui/src/ui/chat/message-extract.ts
./ui/src/ui/chat/tool-cards.ts
./ui/src/ui/chat/tool-helpers.test.ts
./ui/src/ui/chat/message-normalizer.test.ts
./ui/src/ui/chat/constants.ts
./ui/src/ui/chat/tool-helpers.ts
./ui/src/ui/navigation.ts
./ui/src/ui/app-polling.ts
./ui/src/ui/device-identity.ts
./ui/src/ui/app-events.ts
./ui/src/ui/app-chat.ts
./ui/src/ui/theme-transition.ts
./ui/src/ui/chat-markdown.browser.test.ts
./ui/src/ui/app.ts
./ui/src/ui/format.test.ts
./ui/src/ui/markdown.test.ts
./ui/src/ui/storage.ts
./ui/src/ui/app-tool-stream.ts
./ui/src/ui/device-auth.ts
./ui/src/ui/app-scroll.ts
./ui/src/ui/markdown.ts
./ui/src/ui/tool-display.ts
./ui/src/ui/app-channels.ts
./ui/src/ui/app-lifecycle.ts
./ui/src/ui/types.ts
./ui/src/ui/components/resizable-divider.ts
./ui/src/ui/app-gateway.ts
./ui/src/ui/format.ts
./ui/src/ui/app-render.helpers.ts
./ui/src/ui/icons.ts
./ui/src/ui/theme.ts
./ui/src/ui/app-view-state.ts
./ui/src/ui/navigation.browser.test.ts
./ui/src/ui/controllers/devices.ts
./ui/src/ui/controllers/nodes.ts
./ui/src/ui/controllers/channels.tsLet me look for the agent-related code that might use the pi-mono SDK.
>cd /tmp/clawdbot && ls -latotal 4128
drwxr-xr-x@ 52 badlogic wheel 1664 Jan 21 13:42 .
drwxrwxrwt 63 root wheel 2016 Jan 21 13:42 ..
drwxr-xr-x@ 4 badlogic wheel 128 Jan 21 13:42 .agent
-rw-r--r--@ 1 badlogic wheel 1097 Jan 21 13:42 .detect-secrets.cfg
-rw-r--r--@ 1 badlogic wheel 441 Jan 21 13:42 .dockerignore
-rw-r--r--@ 1 badlogic wheel 257 Jan 21 13:42 .env.example
drwxr-xr-x@ 12 badlogic wheel 384 Jan 21 13:42 .git
-rw-r--r--@ 1 badlogic wheel 19 Jan 21 13:42 .gitattributes
drwxr-xr-x@ 4 badlogic wheel 128 Jan 21 13:42 .github
-rw-r--r--@ 1 badlogic wheel 1192 Jan 21 13:42 .gitignore
-rw-r--r--@ 1 badlogic wheel 139 Jan 21 13:42 .npmrc
-rw-r--r--@ 1 badlogic wheel 107 Jan 21 13:42 .oxfmtrc.jsonc
-rw-r--r--@ 1 badlogic wheel 241 Jan 21 13:42 .oxlintrc.json
-rw-r--r--@ 1 badlogic wheel 36 Jan 21 13:42 .prettierignore
-rw-r--r--@ 1 badlogic wheel 14610 Jan 21 13:42 .secrets.baseline
-rw-r--r--@ 1 badlogic wheel 1091 Jan 21 13:42 .swiftformat
-rw-r--r--@ 1 badlogic wheel 2838 Jan 21 13:42 .swiftlint.yml
-rw-r--r--@ 1 badlogic wheel 15677 Jan 21 13:42 AGENTS.md
-rw-r--r--@ 1 badlogic wheel 28657 Jan 21 13:42 appcast.xml
drwxr-xr-x@ 6 badlogic wheel 192 Jan 21 13:42 apps
drwxr-xr-x@ 6 badlogic wheel 192 Jan 21 13:42 assets
-rw-r--r--@ 1 badlogic wheel 89230 Jan 21 13:42 CHANGELOG.md
lrwxr-xr-x@ 1 badlogic wheel 9 Jan 21 13:42 CLAUDE.md -> AGENTS.md
-rw-r--r--@ 1 badlogic wheel 1596 Jan 21 13:42 CONTRIBUTING.md
-rw-r--r--@ 1 badlogic wheel 1347 Jan 21 13:42 docker-compose.yml
-rwxr-xr-x@ 1 badlogic wheel 5896 Jan 21 13:42 docker-setup.sh
-rw-r--r--@ 1 badlogic wheel 909 Jan 21 13:42 Dockerfile
-rw-r--r--@ 1 badlogic wheel 285 Jan 21 13:42 Dockerfile.sandbox
-rw-r--r--@ 1 badlogic wheel 570 Jan 21 13:42 Dockerfile.sandbox-browser
drwxr-xr-x@ 46 badlogic wheel 1472 Jan 21 13:42 docs
-rw-r--r--@ 1 badlogic wheel 5198 Jan 21 13:42 docs.acp.md
drwxr-xr-x@ 23 badlogic wheel 736 Jan 21 13:42 extensions
drwxr-xr-x@ 3 badlogic wheel 96 Jan 21 13:42 git-hooks
-rw-r--r--@ 1 badlogic wheel 1074 Jan 21 13:42 LICENSE
-rw-r--r--@ 1 badlogic wheel 10343 Jan 21 13:42 package.json
drwxr-xr-x@ 4 badlogic wheel 128 Jan 21 13:42 patches
-rw-r--r--@ 1 badlogic wheel 354900 Jan 21 13:42 pnpm-lock.yaml
-rw-r--r--@ 1 badlogic wheel 218 Jan 21 13:42 pnpm-workspace.yaml
-rw-r--r--@ 1 badlogic wheel 1413716 Jan 21 13:42 README-header.png
-rw-r--r--@ 1 badlogic wheel 65309 Jan 21 13:42 README.md
drwxr-xr-x@ 63 badlogic wheel 2016 Jan 21 13:42 scripts
-rw-r--r--@ 1 badlogic wheel 416 Jan 21 13:42 SECURITY.md
drwxr-xr-x@ 54 badlogic wheel 1728 Jan 21 13:42 skills
drwxr-xr-x@ 65 badlogic wheel 2080 Jan 21 13:42 src
drwxr-xr-x@ 15 badlogic wheel 480 Jan 21 13:42 Swabble
drwxr-xr-x@ 10 badlogic wheel 320 Jan 21 13:42 test
-rw-r--r--@ 1 badlogic wheel 538 Jan 21 13:42 tsconfig.json
drwxr-xr-x@ 9 badlogic wheel 288 Jan 21 13:42 ui
drwxr-xr-x@ 3 badlogic wheel 96 Jan 21 13:42 vendor
-rw-r--r--@ 1 badlogic wheel 3217 Jan 21 13:42 vitest.config.ts
-rw-r--r--@ 1 badlogic wheel 590 Jan 21 13:42 vitest.e2e.config.ts
-rw-r--r--@ 1 badlogic wheel 353 Jan 21 13:42 vitest.live.config.tsLet me check for pi-mono or @anthropic references in package.json and look at the main source directory.
>cd /tmp/clawdbot && cat package.json | grep -E "(pi-mono|@anthropic|coding-agent)" | head -20"@mariozechner/pi-coding-agent": "0.49.2",>cd /tmp/clawdbot && ls -la src/total 200
drwxr-xr-x@ 65 badlogic wheel 2080 Jan 21 13:42 .
drwxr-xr-x@ 52 badlogic wheel 1664 Jan 21 13:42 ..
drwxr-xr-x@ 15 badlogic wheel 480 Jan 21 13:42 acp
drwxr-xr-x@ 281 badlogic wheel 8992 Jan 21 13:42 agents
drwxr-xr-x@ 74 badlogic wheel 2368 Jan 21 13:42 auto-reply
drwxr-xr-x@ 69 badlogic wheel 2208 Jan 21 13:42 browser
drwxr-xr-x@ 6 badlogic wheel 192 Jan 21 13:42 canvas-host
-rw-r--r--@ 1 badlogic wheel 567 Jan 21 13:42 channel-web.barrel.test.ts
-rw-r--r--@ 1 badlogic wheel 875 Jan 21 13:42 channel-web.ts
drwxr-xr-x@ 26 badlogic wheel 832 Jan 21 13:42 channels
drwxr-xr-x@ 107 badlogic wheel 3424 Jan 21 13:42 cli
drwxr-xr-x@ 176 badlogic wheel 5632 Jan 21 13:42 commands
drwxr-xr-x@ 109 badlogic wheel 3488 Jan 21 13:42 config
drwxr-xr-x@ 23 badlogic wheel 736 Jan 21 13:42 cron
drwxr-xr-x@ 33 badlogic wheel 1056 Jan 21 13:42 daemon
drwxr-xr-x@ 42 badlogic wheel 1344 Jan 21 13:42 discord
-rw-r--r--@ 1 badlogic wheel 4557 Jan 21 13:42 docker-setup.test.ts
drwxr-xr-x@ 3 badlogic wheel 96 Jan 21 13:42 docs
-rw-r--r--@ 1 badlogic wheel 4352 Jan 21 13:42 entry.ts
drwxr-xr-x@ 123 badlogic wheel 3936 Jan 21 13:42 gateway
-rw-r--r--@ 1 badlogic wheel 3186 Jan 21 13:42 git-hooks.test.ts
-rw-r--r--@ 1 badlogic wheel 802 Jan 21 13:42 globals.test.ts
-rw-r--r--@ 1 badlogic wheel 1042 Jan 21 13:42 globals.ts
drwxr-xr-x@ 30 badlogic wheel 960 Jan 21 13:42 hooks
drwxr-xr-x@ 15 badlogic wheel 480 Jan 21 13:42 imessage
-rw-r--r--@ 1 badlogic wheel 958 Jan 21 13:42 index.test.ts
-rw-r--r--@ 1 badlogic wheel 2797 Jan 21 13:42 index.ts
drwxr-xr-x@ 130 badlogic wheel 4160 Jan 21 13:42 infra
-rw-r--r--@ 1 badlogic wheel 3201 Jan 21 13:42 logger.test.ts
-rw-r--r--@ 1 badlogic wheel 1971 Jan 21 13:42 logger.ts
drwxr-xr-x@ 15 badlogic wheel 480 Jan 21 13:42 logging
-rw-r--r--@ 1 badlogic wheel 1698 Jan 21 13:42 logging.ts
drwxr-xr-x@ 6 badlogic wheel 192 Jan 21 13:42 macos
drwxr-xr-x@ 8 badlogic wheel 256 Jan 21 13:42 markdown
drwxr-xr-x@ 21 badlogic wheel 672 Jan 21 13:42 media
drwxr-xr-x@ 21 badlogic wheel 672 Jan 21 13:42 media-understanding
drwxr-xr-x@ 35 badlogic wheel 1120 Jan 21 13:42 memory
drwxr-xr-x@ 5 badlogic wheel 160 Jan 21 13:42 node-host
drwxr-xr-x@ 7 badlogic wheel 224 Jan 21 13:42 pairing
drwxr-xr-x@ 4 badlogic wheel 128 Jan 21 13:42 plugin-sdk
drwxr-xr-x@ 33 badlogic wheel 1056 Jan 21 13:42 plugins
-rw-r--r--@ 1 badlogic wheel 1056 Jan 21 13:42 polls.test.ts
-rw-r--r--@ 1 badlogic wheel 2025 Jan 21 13:42 polls.ts
-rw-r--r--@ 1 badlogic wheel 5630 Jan 21 13:42 postinstall-patcher.test.ts
drwxr-xr-x@ 9 badlogic wheel 288 Jan 21 13:42 process
drwxr-xr-x@ 10 badlogic wheel 320 Jan 21 13:42 providers
drwxr-xr-x@ 6 badlogic wheel 192 Jan 21 13:42 routing
-rw-r--r--@ 1 badlogic wheel 595 Jan 21 13:42 runtime.ts
drwxr-xr-x@ 8 badlogic wheel 256 Jan 21 13:42 security
drwxr-xr-x@ 9 badlogic wheel 288 Jan 21 13:42 sessions
drwxr-xr-x@ 20 badlogic wheel 640 Jan 21 13:42 signal
drwxr-xr-x@ 29 badlogic wheel 928 Jan 21 13:42 slack
drwxr-xr-x@ 69 badlogic wheel 2208 Jan 21 13:42 telegram
drwxr-xr-x@ 13 badlogic wheel 416 Jan 21 13:42 terminal
drwxr-xr-x@ 3 badlogic wheel 96 Jan 21 13:42 test-helpers
drwxr-xr-x@ 4 badlogic wheel 128 Jan 21 13:42 test-utils
drwxr-xr-x@ 23 badlogic wheel 736 Jan 21 13:42 tui
drwxr-xr-x@ 10 badlogic wheel 320 Jan 21 13:42 types
drwxr-xr-x@ 15 badlogic wheel 480 Jan 21 13:42 utils
-rw-r--r--@ 1 badlogic wheel 5313 Jan 21 13:42 utils.test.ts
-rw-r--r--@ 1 badlogic wheel 8250 Jan 21 13:42 utils.ts
-rw-r--r--@ 1 badlogic wheel 689 Jan 21 13:42 version.ts
drwxr-xr-x@ 47 badlogic wheel 1504 Jan 21 13:42 web
drwxr-xr-x@ 4 badlogic wheel 128 Jan 21 13:42 whatsapp
drwxr-xr-x@ 11 badlogic wheel 352 Jan 21 13:42 wizardThey use @mariozechner/pi-coding-agent. Let me search for where they use this package and look for any pruning-related code.
>cd /tmp/clawdbot && rg -l "pi-coding-agent|@mariozechner" --type tssrc/channels/plugins/message-actions.ts
extensions/matrix/src/tool-actions.ts
src/channels/plugins/actions/discord/handle-action.guild-admin.ts
src/channels/plugins/actions/discord/handle-action.ts
scripts/bench-model.ts
src/providers/github-copilot-models.ts
src/providers/google-shared.ensures-function-call-comes-after-user-turn.test.ts
src/providers/qwen-portal-oauth.ts
src/providers/google-shared.preserves-parameters-type-is-missing.test.ts
src/plugins/types.ts
src/channels/plugins/types.core.ts
src/agents/model-auth.ts
src/agents/pi-embedded-subscribe.subscribe-embedded-pi-session.subscribeembeddedpisession.test.ts
src/agents/pi-embedded-runner.splitsdktools.test.ts
src/agents/pi-embedded-subscribe.subscribe-embedded-pi-session.suppresses-message-end-block-replies-message-tool.test.ts
src/agents/model-compat.test.ts
src/tui/tui-session-actions.ts
src/agents/pi-embedded-subscribe.handlers.lifecycle.ts
src/agents/pi-embedded-runner.run-embedded-pi-agent.appends-new-user-assistant-after-existing-transcript.test.ts
src/tui/theme/theme.ts
src/agents/model-compat.ts
src/tui/tui-overlays.ts
src/agents/pi-tools.create-clawdbot-coding-tools.adds-claude-style-aliases-schemas-without-dropping-e.test.ts
src/tui/components/custom-editor.ts
src/tui/components/filterable-select-list.ts
src/agents/pi-embedded-helpers/bootstrap.ts
src/tui/components/searchable-select-list.ts
src/tui/components/tool-execution.ts
src/agents/pi-embedded-helpers/google.ts
src/tui/components/selectors.ts
src/tui/components/chat-log.ts
src/agents/pi-embedded-helpers/turns.ts
src/tui/components/assistant-message.ts
src/agents/pi-embedded-helpers/images.ts
src/agents/pi-embedded-helpers/errors.ts
src/tui/components/user-message.ts
src/agents/models.profiles.live.test.ts
src/tui/tui-command-handlers.ts
src/agents/pi-embedded-helpers.validate-turns.test.ts
src/tui/tui-event-handlers.ts
src/tui/tui.ts
src/agents/pi-tools.create-clawdbot-coding-tools.adds-claude-style-aliases-schemas-without-dropping-d.test.ts
src/tui/commands.ts
src/tui/tui-overlays.test.ts
src/agents/pi-embedded-subscribe.subscribe-embedded-pi-session.emits-reasoning-as-separate-message-enabled.test.ts
src/agents/pi-tools.types.ts
src/auto-reply/reply/session.ts
src/agents/model-catalog.test.ts
src/agents/pi-embedded-helpers.formatassistanterrortext.test.ts
src/agents/cli-runner.ts
src/agents/pi-embedded-subscribe.subscribe-embedded-pi-session.streams-soft-chunks-paragraph-preference.test.ts
src/agents/tools/image-tool.ts
src/agents/tools/discord-actions-moderation.ts
src/agents/cli-credentials.ts
src/agents/pi-embedded-helpers.sanitizesessionmessagesimages-thought-signature-stripping.test.ts
src/agents/pi-embedded-runner.google-sanitize-thinking.test.ts
src/agents/skills/frontmatter.ts
src/config/sessions/transcript.ts
src/agents/tools/discord-actions-messaging.ts
src/config/sessions/types.ts
src/commands/onboard-auth.credentials.ts
src/gateway/test-helpers.mocks.ts
src/commands/onboard-auth.test.ts
src/gateway/gateway-models.profiles.live.test.ts
src/agents/tools/slack-actions.ts
src/agents/skills/types.ts
src/agents/tools/common.ts
src/agents/skills/workspace.ts
src/commands/models.list.test.ts
src/agents/tools/image-tool.helpers.ts
src/commands/chutes-oauth.ts
src/agents/google-gemini-switch.live.test.ts
src/agents/tools/telegram-actions.ts
src/commands/auth-choice.apply.openai.ts
src/agents/pi-embedded-runner.resolvesessionagentids.test.ts
src/agents/tools/discord-actions-guild.ts
src/agents/tool-images.ts
src/agents/tools/nodes-tool.ts
src/agents/models-config.providers.ts
src/agents/openai-responses.reasoning-replay.test.ts
src/agents/tools/whatsapp-actions.ts
src/agents/pi-embedded-runner.guard.test.ts
src/commands/models/list.registry.ts
src/agents/tools/discord-actions.ts
src/agents/pi-embedded-subscribe.subscribe-embedded-pi-session.reopens-fenced-blocks-splitting-inside-them.test.ts
src/agents/pi-embedded-runner.sanitize-session-history.test.ts
src/agents/pi-tools.read.ts
src/agents/pi-embedded-runner.get-dm-history-limit-from-session-key.returns-undefined-sessionkey-is-undefined.test.ts
src/agents/session-tool-result-guard.test.ts
src/agents/pi-embedded-subscribe.subscribe-embedded-pi-session.emits-block-replies-text-end-does-not.test.ts
src/agents/pi-tools.create-clawdbot-coding-tools.adds-claude-style-aliases-schemas-without-dropping-f.test.ts
src/agents/model-scan.ts
src/commands/models/list.list-command.ts
src/agents/session-transcript-repair.ts
src/agents/bash-tools.exec.ts
src/agents/pi-embedded-subscribe.handlers.types.ts
src/agents/pi-embedded-runner.get-dm-history-limit-from-session-key.falls-back-provider-default-per-dm-not.test.ts
src/agents/pi-embedded-runner.run-embedded-pi-agent.auth-profile-rotation.test.ts
src/agents/pi-embedded-subscribe.types.ts
src/agents/session-transcript-repair.test.ts
src/agents/pi-tools.ts
src/agents/auth-profiles/store.ts
src/agents/tool-summaries.ts
src/agents/pi-embedded-runner.buildembeddedsandboxinfo.test.ts
src/agents/bash-tools.process.ts
src/agents/pi-tools.create-clawdbot-coding-tools.adds-claude-style-aliases-schemas-without-dropping.test.ts
src/agents/apply-patch.ts
src/agents/pi-tools.create-clawdbot-coding-tools.adds-claude-style-aliases-schemas-without-dropping-a.test.ts
src/agents/pi-embedded-helpers.sanitizegoogleturnordering.test.ts
src/agents/pi-embedded-runner.applygoogleturnorderingfix.test.ts
src/agents/auth-profiles/types.ts
src/agents/pi-tools.create-clawdbot-coding-tools.adds-claude-style-aliases-schemas-without-dropping-b.test.ts
src/agents/session-tool-result-guard.tool-result-persist-hook.test.ts
src/agents/auth-profiles/oauth.ts
src/agents/model-auth.test.ts
src/agents/anthropic.setup-token.live.test.ts
src/agents/pi-tool-definition-adapter.test.ts
src/agents/pi-embedded-subscribe.subscribe-embedded-pi-session.filters-final-suppresses-output-without-start-tag.test.ts
src/agents/pi-embedded-runner-extraparams.live.test.ts
src/agents/pi-embedded-subscribe.subscribe-embedded-pi-session.does-not-emit-duplicate-block-replies-text.test.ts
src/agents/pi-embedded-subscribe.subscribe-embedded-pi-session.splits-long-single-line-fenced-blocks-reopen.test.ts
src/agents/context.ts
src/agents/pi-embedded-helpers.sanitize-session-messages-images.removes-empty-assistant-text-blocks-but-preserves.test.ts
src/agents/tool-call-id.test.ts
src/agents/pi-embedded-runner.run-embedded-pi-agent.writes-models-json-into-provided-agentdir.test.ts
src/agents/cli-runner/helpers.ts
src/agents/model-catalog.ts
src/agents/session-tool-result-guard.ts
src/agents/pi-embedded-subscribe.subscribe-embedded-pi-session.keeps-assistanttexts-final-answer-block-replies-are.test.ts
src/media-understanding/providers/image.ts
src/agents/pi-tool-definition-adapter.ts
src/agents/pi-embedded-utils.ts
src/agents/pi-embedded-subscribe.handlers.tools.ts
src/agents/chutes-oauth.ts
src/agents/zai.live.test.ts
src/agents/system-prompt-report.ts
src/agents/pi-tools.create-clawdbot-coding-tools.adds-claude-style-aliases-schemas-without-dropping-g.test.ts
src/agents/minimax.live.test.ts
src/agents/pi-embedded-runner.limithistoryturns.test.ts
src/agents/pi-extensions/transcript-sanitize.ts
src/agents/tool-call-id.ts
src/agents/pi-extensions/compaction-safeguard.ts
src/agents/cache-trace.ts
src/agents/pi-extensions/compaction-safeguard.test.ts
src/agents/pi-extensions/context-pruning.test.ts
src/agents/pi-embedded-runner/tool-split.ts
src/agents/pi-extensions/context-pruning/pruner.ts
src/agents/pi-extensions/context-pruning/extension.ts
src/agents/pi-embedded-helpers.sanitize-session-messages-images.keeps-tool-call-tool-result-ids-unchanged.test.ts
src/agents/pi-embedded-utils.test.ts
src/agents/pi-embedded-runner/run/attempt.ts
src/agents/session-tool-result-guard-wrapper.ts
src/agents/pi-embedded-runner/run/params.ts
src/agents/pi-embedded-subscribe.handlers.messages.ts
src/agents/pi-embedded-runner.createsystempromptoverride.test.ts
src/agents/pi-embedded-runner/run/types.ts
src/agents/pi-embedded-subscribe.subscribe-embedded-pi-session.keeps-indented-fenced-blocks-intact.test.ts
src/agents/pi-embedded-runner/model.ts
src/agents/pi-embedded-runner/run/payloads.ts
src/agents/pi-embedded-runner/google.test.ts
src/agents/pi-embedded-runner/extensions.ts
src/agents/pi-embedded-runner/run/images.ts
src/agents/pi-embedded-runner/extra-params.ts
src/agents/pi-embedded-runner/session-manager-init.ts
src/agents/pi-embedded-runner/compact.ts
src/agents/pi-embedded-runner/utils.ts
src/agents/pi-embedded-runner/run/payloads.test.ts
src/agents/pi-embedded-runner/system-prompt.ts
src/agents/pi-embedded-runner/history.ts
src/agents/pi-embedded-runner/google.ts
src/infra/outbound/outbound-send-service.ts
src/infra/outbound/message-action-runner.ts>cd /tmp/clawdbot && rg -l "prune|pruning|truncate|compaction" --type ts -isrc/sessions/model-overrides.ts
src/cron/service/normalize.ts
src/cron/service/state.ts
src/browser/pw-tools-core.snapshot.ts
src/pairing/pairing-store.ts
src/cron/run-log.ts
src/cron/isolated-agent/run.ts
src/imessage/monitor/monitor-provider.ts
src/cron/isolated-agent/helpers.ts
src/telegram/draft-stream.ts
src/node-host/runner.ts
src/cron/run-log.test.ts
src/cron/types.ts
src/cron/isolated-agent.uses-last-non-empty-agent-text-as.test.ts
src/auto-reply/reply/agent-runner.heartbeat-typing.runreplyagent-typing-heartbeat.retries-after-compaction-failure-by-resetting-session.test.ts
src/browser/pw-tools-core.waits-next-download-saves-it.test.ts
src/web/auto-reply/util.ts
src/gateway/session-utils.test.ts
src/auto-reply/reply/agent-runner.authprofileid-fallback.test.ts
src/browser/client.ts
src/auto-reply/reply/followup-runner.compaction.test.ts
src/gateway/server.ts
src/browser/cdp.ts
src/auto-reply/reply/commands-context-report.ts
src/auto-reply/reply/agent-runner.memory-flush.runreplyagent-memory-flush.uses-configured-prompts-memory-flush-runs.test.ts
src/auto-reply/reply/commands-compact.ts
src/commands/sessions.ts
src/auto-reply/reply/agent-runner.memory-flush.runreplyagent-memory-flush.increments-compaction-count-flush-compaction-completes.test.ts
src/browser/pw-tools-core.responses.ts
src/commands/doctor-sandbox.ts
src/browser/client-actions-observe.ts
src/gateway/server-methods/logs.ts
src/gateway/server-methods/agent-job.ts
src/browser/pw-ai.test.ts
src/commands/doctor.warns-per-agent-sandbox-docker-browser-prune.test.ts
extensions/msteams/src/conversation-store-fs.test.ts
src/auto-reply/reply/subagents-utils.ts
src/commands/agents.commands.delete.ts
src/auto-reply/reply/agent-runner.reasoning-tags.test.ts
src/auto-reply/reply/session.ts
src/auto-reply/reply/agent-runner.memory-flush.runreplyagent-memory-flush.skips-memory-flush-cli-providers.test.ts
src/web/session.ts
src/auto-reply/reply/agent-runner.heartbeat-typing.runreplyagent-typing-heartbeat.signals-typing-block-replies.test.ts
src/commands/agents.test.ts
extensions/msteams/src/conversation-store-fs.ts
src/auto-reply/reply/agent-runner.ts
src/auto-reply/reply/memory-flush.ts
extensions/msteams/src/polls.ts
src/auto-reply/reply/session-reset-model.test.ts
src/auto-reply/reply/agent-runner-execution.ts
src/cli/program/register.agent.ts
src/auto-reply/reply/memory-flush.test.ts
src/auto-reply/reply/followup-runner.ts
src/auto-reply/reply/agent-runner-memory.ts
extensions/nextcloud-talk/src/format.ts
src/auto-reply/reply/agent-runner.memory-flush.runreplyagent-memory-flush.skips-memory-flush-sandbox-workspace-is-read.test.ts
src/plugins/hooks.ts
src/auto-reply/reply/agent-runner.memory-flush.runreplyagent-memory-flush.runs-memory-flush-turn-updates-session-metadata.test.ts
src/auto-reply/reply/session-updates.ts
src/gateway/protocol/schema/logs-chat.ts
src/commands/models/list.format.ts
src/plugins/types.ts
src/commands/models/scan.ts
src/commands/models/list.table.ts
src/commands/agents.config.ts
src/auto-reply/status.test.ts
src/gateway/server/close-reason.ts
src/auto-reply/commands-registry.data.ts
src/gateway/server/ws-connection/message-handler.ts
src/auto-reply/status.ts
extensions/nostr/src/nostr-profile.fuzz.test.ts
src/cli/cron-cli/shared.ts
src/auto-reply/reply.triggers.trigger-handling.runs-compact-as-gated-command.test.ts
extensions/nostr/src/seen-tracker.ts
src/tui/components/searchable-select-list.ts
src/cli/logs-cli.ts
src/logging/logger.ts
src/gateway/session-utils.ts
src/logger.test.ts
extensions/nostr/src/nostr-bus.integration.test.ts
src/gateway/sessions-patch.test.ts
scripts/readability-basic-compare.ts
scripts/firecrawl-compare.ts
src/cli/logs-cli.test.ts
ui/src/ui/app.ts
src/config/schema.ts
src/config/config.pruning-defaults.test.ts
src/config/zod-schema.agent-runtime.ts
ui/src/ui/views/config.ts
ui/src/ui/chat/tool-helpers.ts
src/config/zod-schema.agent-defaults.ts
ui/src/ui/chat/tool-helpers.test.ts
src/config/types.agent-defaults.ts
ui/src/ui/chat/tool-cards.ts
src/config/config.compaction-settings.test.ts
src/config/types.agents.ts
ui/src/ui/app-render.ts
src/config/types.sandbox.ts
src/config/runtime-overrides.test.ts
src/memory/manager-search.ts
src/config/sessions.test.ts
ui/src/ui/views/logs.ts
src/config/defaults.ts
ui/src/ui/format.ts
src/memory/manager.ts
ui/src/ui/markdown.ts
ui/src/ui/views/channels.nostr.ts
src/config/io.ts
ui/src/ui/app-tool-stream.ts
src/config/sessions/store.ts
src/agents/pi-embedded-subscribe.tools.ts
src/agents/pi-settings.test.ts
src/agents/bash-process-registry.test.ts
src/config/sessions/types.ts
src/agents/tools/web-tools.fetch.test.ts
src/utils.ts
ui/src/ui/app-view-state.ts
ui/src/ui/controllers/exec-approval.ts
src/discord/monitor/message-handler.process.ts
ui/src/ui/controllers/logs.ts
src/agents/bash-tools.exec.ts
src/discord/monitor/threading.ts
src/agents/pi-embedded-subscribe.subscribe-embedded-pi-session.waits-multiple-compaction-retries-before-resolving.test.ts
src/agents/tools/cron-tool.ts
src/agents/pi-embedded-helpers.iscompactionfailureerror.test.ts
src/agents/pi-embedded-subscribe.handlers.lifecycle.ts
src/agents/tools/web-fetch-utils.ts
src/agents/pi-settings.ts
src/agents/tools/common.test.ts
src/agents/pi-embedded-helpers.ts
src/agents/tools/image-tool.ts
src/agents/tools/web-fetch.ts
src/agents/skills.buildworkspaceskillcommands.test.ts
src/infra/update-runner.test.ts
src/agents/pi-embedded-helpers/bootstrap.ts
src/agents/pi-embedded-subscribe.handlers.types.ts
src/agents/pi-embedded-subscribe.handlers.ts
src/agents/pi-embedded-helpers/errors.ts
src/agents/sandbox.ts
src/agents/bash-tools.process.ts
src/agents/sandbox-merge.test.ts
src/agents/pi-embedded-helpers.buildbootstrapcontextfiles.test.ts
src/agents/pi-extensions/compaction-safeguard.ts
src/agents/pi-extensions/compaction-safeguard.test.ts
src/agents/bash-tools.shared.ts
src/agents/pi-extensions/context-pruning.ts
src/agents/bash-process-registry.ts
src/agents/pi-extensions/context-pruning.test.ts
src/agents/pi-extensions/context-pruning/tools.ts
src/agents/pi-extensions/context-pruning/runtime.ts
src/agents/system-prompt-report.ts
src/agents/pi-extensions/context-pruning/extension.ts
src/agents/pi-extensions/context-pruning/pruner.ts
src/agents/sandbox/config.ts
src/agents/pi-extensions/context-pruning/settings.ts
src/agents/pi-embedded-subscribe.ts
src/agents/pi-embedded-runner/run.ts
src/agents/sandbox/context.ts
src/agents/sandbox/prune.ts
src/agents/sandbox/types.ts
src/agents/pi-embedded-subscribe.subscribe-embedded-pi-session.splits-long-single-line-fenced-blocks-reopen.test.ts
src/agents/pi-embedded-runner/run/attempt.ts
src/agents/pi-embedded-runner/types.ts
src/agents/pi-embedded-runner/extensions.ts
src/agents/pi-embedded-runner/google.ts
src/agents/pi-embedded-runner/compact.ts
src/agents/auth-profiles/session-override.ts
src/infra/dedupe.test.ts
src/infra/node-pairing.ts
src/infra/device-pairing.ts
src/infra/agent-events.test.ts
src/infra/system-presence.ts
src/infra/update-runner.ts
src/infra/dedupe.ts
src/infra/update-check.tsThere's a lot of pruning and compaction-related code. Let me examine the key files related to context pruning and tool result handling:
Good, they have dedicated files for context pruning. Let me examine the key files:
Excellent! This is very revealing. Let me also check the settings and the compact.ts file:
Let me also check the settings and the compact logic:
Now let me look at the compaction safeguard extension as well to get a complete picture:
Now I have a comprehensive view of their implementation. Let me summarize the findings:
Clawdbot implements comprehensive history and tool result pruning using the pi-coding-agent SDK. Here's what they built:
pi-extensions/context-pruning/)A pi-coding-agent extension that hooks into the context event to prune tool results before they're sent to the LLM.
Two modes:
adaptive: Progressively trims tool results based on context window utilization
"[Old tool result content cleared]"aggressive: Immediately clears all prunable tool results outside the protected tail
Key settings:
keepLastAssistants: 3 - protects the last 3 assistant turns from any pruningpi-embedded-runner/history.ts)Limits conversation history to the last N user turns for long-running DM sessions. Configurable per-provider and per-user via dmHistoryLimit.
session-tool-result-guard.ts)Monkey-patches SessionManager.appendMessage to:
<final> tags from assistant text before persistencetransformToolResultForPersistence hook for pre-persist transformationspi-extensions/compaction-safeguard.ts)Hooks into session_before_compact to generate summaries when the SDK's built-in compaction triggers:
All this is wired into the embedded pi runner via buildEmbeddedExtensionPaths() which registers these as SDK extensions:
const additionalExtensionPaths = buildEmbeddedExtensionPaths({ cfg: params.config, sessionManager, provider, modelId, model,});The pruning uses char-based estimates (4 chars/token) rather than precise token counting for performance.
const additionalExtensionPaths = buildEmbeddedExtensionPaths({ cfg: params.config, sessionManager, provider, modelId, model,});