Skip to content

emrg: memory reflection tool log — session id + round + truncation marker - #815

Closed
argszero wants to merge 1 commit into
masterfrom
feature/reflection-log-readability
Closed

emrg: memory reflection tool log — session id + round + truncation marker#815
argszero wants to merge 1 commit into
masterfrom
feature/reflection-log-readability

Conversation

@argszero

Copy link
Copy Markdown
Owner

Host rant 2026-08-17T12:00:35: memory reflection tool: bash → --- in emrgd.log is unclear — no context (which background task), no session id (sibling logs carry id=%s round=%d), and the truncated --- looks like meaningless output rather than the first 100 chars of a YAML frontmatter.

Change (log-only, 6+/1-):

  • Prefix unified to memory reflection: (matches sibling logs in _maybe_reflect_memory)
  • Added id=<session_id> round=<n> (1-based tool-loop round)
  • Result truncated to 100 chars gets a suffix when longer — unambiguous that the output was cut

New form: memory reflection: id=s_xxx round=2 tool bash → ---…

No test changes (Agent.md count unchanged).

…tion marker

Host rant 2026-08-17T12:00:35: 'memory reflection tool: bash → ---' was
unclear — no context (which background task), no session id (other lines in
the same function carry id=%s round=%d), and the truncated '---' looked like
meaningless output rather than the first 100 chars of a YAML frontmatter.

- Prefix unified to 'memory reflection:' (matches sibling logs)
- Added id=<session_id> round=<n> (the for-loop round, 1-based)
- Result truncated to 100 chars with a '…' suffix when longer, so it is
  unambiguous that the output was cut.

Example: memory reflection: id=s_xxx round=2 tool bash → ---…

No test changes (log-only).

@argszero argszero left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ LGTM — cycle (self-review): log-only change; prefix unified to memory reflection: with id/round, 100-char truncation gains a … marker. Sibling logs already carry id/round — consistent. No test impact.

@argszero

Copy link
Copy Markdown
Owner Author

Superseding this PR: the same memory-reflection log fix (id/round/truncation marker) is now contained in #814 (feature/submit-rant-tool), which additionally adds the tool purpose field (rant 12:03:13) to the same log line — a superset. Keeping both would conflict on that line, so this PR is closed in favor of #814. The 12:00:35 rant is covered by #814.

@argszero argszero closed this Aug 17, 2026
argszero pushed a commit that referenced this pull request Aug 17, 2026
… 2026-08-17T12:03:13)

Host: every agent tool log should output 'tool name + human-readable
purpose' so background calls (memory reflection / consolidation) are
understandable without context. Also submit_rant's project becomes
REQUIRED (host 12:00 demand folded into this rant).

- ToolDefinition gains purpose: human-friendly one-line purpose
  (logs/UI); description stays for LLM routing.
- All 7 tools (bash/read/write/edit/glob/grep/submit_rant) get a purpose.
- Log sites now print 'name — purpose (args)':
  * main loop: 'tool call: bash — 执行 shell 命令并返回输出 ({command: ...})'
  * memory reflection: 'memory reflection: id= round= tool name — purpose → out…'
  * consolidation: 'consolidation tool: name — purpose → out…'
  (unknown tool → purpose 'unknown tool'; tool mocks in tests updated)
- submit_rant: parameters.required now ['project','message']; execute
  rejects empty project with 'ask the user which project this rant targets'.
- system.j2 Rant Handling: tool requires project — ask user if unknown.

Also covers rant 2026-08-17T12:00:35 (memory reflection log id/round/
truncation marker) — same log line, superset, #815 closed.

+2 tests (project-required, all-tools-have-purpose), Agent.md 841→843.
@pm25coder

Copy link
Copy Markdown
Contributor

I tested PR #815 end-to-end (checked out 9645dcb7) and it verifies clean.

  • Diff matches the description exactly: 1 file, daemon.py 6+/1- (log-only, no test/doc changes).
  • Prefix unification confirmed: the new line at daemon.py:3448 mirrors the existing sibling logs in _maybe_reflect_memory (memory reflection: id=%s round=%d ... at lines 3390-3391 and 3396-3397), so the "unified prefix" claim is accurate and id=<session_id> round=<round+1> are the same fields the sibling logs carry.
  • Truncation marker is accurate: the suffix is gated on len(result_text) > 100, i.e. only emitted when the [:100] slice actually cut something — so the reader can distinguish a full ≤100-char result from a truncated one.
  • Verification: pytest 834 collected (774 passed + 60 skipped) green, from emrg.client.app import run_client import OK, python -m emrg --help OK.

One non-blocking observation for a future slice: the marker reflects the original result_text length, but the displayed text passes through _redact_string first — if redaction shortens the string (e.g. a long inline credential replaced by a placeholder), the display can be shorter than 100 chars while still showing . Purely cosmetic in a debug log, so not worth changing now — just noting the semantics.

argszero added a commit that referenced this pull request Aug 17, 2026
…hen-write) (#814)

* emrg: submit_rant tool + rant in normal conversation (rant 2026-08-17T11:51:59)

Host: a rant is not a special mode — it is a normal part of conversation.
The user may complain/suggest in plain speech; the agent should detect
rant intent, clarify/polish, get explicit consent, then write it.

- New emrg/server/rants.py: append_rant() shared write logic (field order
  timestamp → project → status → progress → completed → message, tz-aware
  daemon-authoritative timestamp, sorted rewrite) — extracted from the
  daemon rant handler, single source of truth.
- New emrg/tools/submit_rant_tool.py: SubmitRantTool registered in the
  daemon tool registry (available in every session); description mandates
  explicit user consent before calling; project optional (default = emrg).
- daemon.py rant handler now delegates to append_rant (identical behavior).
- system.j2: new 'Rant Handling' section — recognition (no /rant prefix
  needed), confirm → clarify → polish → show → call submit_rant; never
  call without explicit agreement; /rant <msg> and GUI panel are explicit.
- TUI /rant <msg> / /rant @Proj <msg> no longer write directly: routes
  through the agent as a normal task with a '[Host wants to submit this
  rant…]' hint (agent confirms + calls submit_rant). GUI panel keeps the
  direct write (explicit form submit = confirmed).
- +7 tests (append_rant sort/field-order/corrupt-skip, tool write/count,
  empty-message error, definition consent contract, system.j2 section,
  tool registered). Agent.md 834→841.

* emrg: tool purpose field in logs + submit_rant project required (rant 2026-08-17T12:03:13)

Host: every agent tool log should output 'tool name + human-readable
purpose' so background calls (memory reflection / consolidation) are
understandable without context. Also submit_rant's project becomes
REQUIRED (host 12:00 demand folded into this rant).

- ToolDefinition gains purpose: human-friendly one-line purpose
  (logs/UI); description stays for LLM routing.
- All 7 tools (bash/read/write/edit/glob/grep/submit_rant) get a purpose.
- Log sites now print 'name — purpose (args)':
  * main loop: 'tool call: bash — 执行 shell 命令并返回输出 ({command: ...})'
  * memory reflection: 'memory reflection: id= round= tool name — purpose → out…'
  * consolidation: 'consolidation tool: name — purpose → out…'
  (unknown tool → purpose 'unknown tool'; tool mocks in tests updated)
- submit_rant: parameters.required now ['project','message']; execute
  rejects empty project with 'ask the user which project this rant targets'.
- system.j2 Rant Handling: tool requires project — ask user if unknown.

Also covers rant 2026-08-17T12:00:35 (memory reflection log id/round/
truncation marker) — same log line, superset, #815 closed.

+2 tests (project-required, all-tools-have-purpose), Agent.md 841→843.

* test: append_rant sort test uses host-local offset (UTC CI fix)

The older-rant fixture hardcoded a +08:00 timestamp; on UTC CI hosts the
daemon writes +00:00, so the lexicographic string sort puts the new entry
first and the order assertion failed. Production is unaffected (all rants
share the host offset), but the test must too — compute the older timestamp
as now - 1h in the host's own tz. Verified under TZ=UTC and TZ=Asia/Shanghai.

---------

Co-authored-by: EMRG Evolution <emrg@argszero.dev>
@argszero
argszero deleted the feature/reflection-log-readability branch August 17, 2026 09:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants