Skip to content

Commit 0f4e780

Browse files
author
codejunkie99
committed
review: fix P2 findings from codex pre-merge review
Final codex review surfaced two P2s that would break upgrades and downstream salience. 1. install.sh:148 / install.ps1 — the top-level `.agent/` copy is skipped when the target already has one (line 39-42 / 45-48). So on an upgrade install of an older agentic-stack project, the pi extension's `memory-hook.ts` gets dropped, but the Python hook it invokes (`.agent/harness/hooks/pi_post_tool.py`) never arrives. Every `tool_result` then fires `missing-hook` forever. Fix: sync `pi_post_tool.py` explicitly in the pi case, both installers. 2. pi_post_tool.py:152 — `_emit_malformed()` was writing `importance="medium"` (string). Downstream `salience_score()` does `importance / 10.0`, which raises TypeError on a string and would crash context_budget.py, show.py, and auto_dream.py readers of AGENT_LEARNINGS.jsonl. Fix: use int 5 (middle of the 1-10 scale). Smoke-tested: - empty payload → entry has `importance: 5` (int), salience_score runs to 1.000 without error - upgrade install on a project with old .agent/ (no pi_post_tool.py) → "synced for upgrades" line fires, file now present
1 parent d790769 commit 0f4e780

3 files changed

Lines changed: 18 additions & 1 deletion

File tree

.agent/harness/hooks/pi_post_tool.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,13 +143,16 @@ def _emit_malformed(reason: str, raw_excerpt: str) -> None:
143143
JSON, this surfaces in AGENT_LEARNINGS.jsonl as a real signal.
144144
"""
145145
excerpt = raw_excerpt[:200] if isinstance(raw_excerpt, str) else ""
146+
# importance MUST be numeric — downstream salience_score() does
147+
# `importance / 10.0` and a string would crash context_budget,
148+
# show.py, and auto_dream readers. 5 ≈ "medium" on the 1-10 scale.
146149
on_failure(
147150
skill_name="pi",
148151
action="hook:malformed_payload",
149152
error=f"pi tool_result payload malformed: {reason}",
150153
context=excerpt,
151154
confidence=0.95,
152-
importance="medium",
155+
importance=5,
153156
pain_score=2,
154157
)
155158

install.ps1

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,13 @@ switch ($Adapter) {
182182
New-Item -ItemType Directory -Path $extensionsDir -Force | Out-Null
183183
Copy-Item (Join-Path $Src 'memory-hook.ts') (Join-Path $extensionsDir 'memory-hook.ts') -Force
184184
Write-Host " + .pi/extensions/memory-hook.ts"
185+
# Upgrade path: the .agent copy higher up is skipped when .agent
186+
# already exists, but the pi extension calls this python hook,
187+
# so sync it explicitly.
188+
$hooksDir = Join-Path $TargetAgent 'harness/hooks'
189+
New-Item -ItemType Directory -Path $hooksDir -Force | Out-Null
190+
Copy-Item (Join-Path $Here '.agent/harness/hooks/pi_post_tool.py') (Join-Path $hooksDir 'pi_post_tool.py') -Force
191+
Write-Host " + .agent/harness/hooks/pi_post_tool.py (synced for upgrades)"
185192
}
186193
'standalone-python' {
187194
Copy-Item (Join-Path $Src 'run.py') (Join-Path $TargetDir 'run.py') -Force

install.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,13 @@ case "$ADAPTER" in
147147
mkdir -p "$TARGET/.pi/extensions"
148148
cp "$SRC/memory-hook.ts" "$TARGET/.pi/extensions/memory-hook.ts"
149149
echo " + .pi/extensions/memory-hook.ts"
150+
# Upgrade path: the top-level `.agent/` copy at line 39-42 is skipped
151+
# when .agent already exists, but the pi extension calls this python
152+
# hook, so sync it explicitly for installs on older agentic-stack
153+
# projects that don't already have it.
154+
mkdir -p "$TARGET/.agent/harness/hooks"
155+
cp "$HERE/.agent/harness/hooks/pi_post_tool.py" "$TARGET/.agent/harness/hooks/pi_post_tool.py"
156+
echo " + .agent/harness/hooks/pi_post_tool.py (synced for upgrades)"
150157
;;
151158
standalone-python)
152159
cp "$SRC/run.py" "$TARGET/run.py"

0 commit comments

Comments
 (0)