Skip to content

Improve agent runtime correctness from upstream Pi audit #99924

Description

@steipete

Summary

Adopt the current, proven runtime correctness improvements from the upstream Pi agent stack where OpenClaw still carries equivalent older behavior.

Problem to solve

An audit against earendil-works/pi v0.80.3 and current main found several user-visible correctness gaps in OpenClaw's inherited or parallel runtime surfaces: fuzzy edits can rewrite untouched whitespace, model-added edit metadata fails validation, nested-repository find behavior can ignore the wrong rules, descendant process output can be truncated, late tool progress can leak after completion, compaction summaries can race, provider overflow and retry wording can be missed, ChatGPT transport reuse can exceed backend limits, and BMP reads are not normalized for model input.

The root TUI dependency also trails two minor releases containing upstream rendering and input fixes.

Proposed solution

Port the bounded upstream fixes into the existing OpenClaw owner boundaries, retaining OpenClaw's strict provider schemas and shared media/runtime abstractions. Add focused regression tests for every changed behavior, upgrade @earendil-works/pi-tui to the current stable release, and validate the aggregate through targeted tests, remote changed gates, a package build, and a live OpenAI/Codex agent scenario.

Non-goals: importing Pi's model registry, orchestrator, RPC shell, or project-trust architecture; replacing OpenClaw's existing unified/multi-edit support; adding compatibility shims or new config.

Alternatives considered

  • Wait for failures to be reported individually: weaker because the bugs are already reproducible and upstream has focused fixes with regression coverage.
  • Replace OpenClaw's runtime with newer Pi packages wholesale: too broad and conflicts with current OpenClaw ownership boundaries.
  • Relax edit tool schemas: rejected because strict OpenAI tool schemas remain useful; normalize model-added metadata before validation instead.

Impact

  • Affected: users relying on agent file tools, long-running commands, compaction, ChatGPT-authenticated OpenAI transport, image reads, and the terminal UI.
  • Severity: correctness and reliability; several cases silently alter output or lose data.
  • Frequency: input-dependent but deterministic when triggered.
  • Consequence: damaged formatting, missed files/output, duplicate or late progress, failed retries, stale connections, rejected images, and older TUI behavior.

Evidence/examples

  • Current fuzzy edit reproduction changes untouched whitespace.
  • Current edit validation rejects an otherwise valid edit containing a model-generated reason field.
  • Current fd --no-require-git behavior fails to re-enable nested-repository ignore rules.
  • Current DeepSeek-style overflow text with raw token counts is not classified as context overflow.
  • Official Codex source compresses authenticated Responses requests with zstd and explicitly reconnects on WebSocket connection-limit errors.
  • Upstream Pi changes are individually scoped and covered by tests; OpenClaw already has matching owner surfaces for each selected adoption.

Additional information

This is maintainer-directed implementation work. No public config, protocol, or storage shape changes are planned.

Metadata

Metadata

Assignees

Labels

P0Emergency: data loss, security bypass, crash loop, or unusable core runtime.clawsweeper:fix-shape-clearClawSweeper found a clear likely implementation shape for this issue.clawsweeper:needs-live-reproClawSweeper needs live local, crabbox, or manual validation to confirm this issue.clawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.enhancementNew feature or requestimpact:auth-providerAuth, provider routing, model choice, or SecretRef resolution may break.impact:data-lossCan lose, corrupt, or silently drop user/session/config data.impact:session-stateSession, memory, transcript, context, or agent state can drift or corrupt.issue-rating: 🐚 platinum hermitGood issue quality with a plausible reproduction path needing some confirmation.maintainerMaintainer-authored PR

Type

No type

Fields

Priority

None yet

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions