fix(sight): classify analyzer calls as internal - #2755
Conversation
cosh-shell's personal analyzer runs in a setsid child with a
fixed prompt ("Summarize only grounded work..."); the pid-keyed
session LRU gives it a new session_id and the prompt matched no
recap marker, so it surfaced as a 0-token main session (#2750).
Add the prompt prefix to both classify_call_kind paths; events
now classify as recap and stay out of the session list.
Refs #2750 (parent-session merge needs a separate design)
Assisted-by: Qoder
Signed-off-by: Jiangtian Feng <jiangtianf97@163.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1f9f00f01c
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
chengshuyi
left a comment
There was a problem hiding this comment.
LGTM. Minimal, pattern-consistent fix (Footprint Ladder L1). Both structured and raw classification paths covered; 4 discriminating tests (positive + negative per path); graceful degradation if cosh-ng prompt changes. No correctness, safety, or architecture concerns.
Non-blocking observations:
- F1: prefix string couples to cosh-ng build_fixed_prompt wording; accepted degradation documented in PR.
- F2: ~8 hardcoded prefixes now in helpers.rs; consider table-driven extraction if the list keeps growing.
Why
cosh-shell's personalization analyzer (not a recap — root cause corrected in the issue comment) spawns a
setsid()cosh-core child after 3s foreground idle with a fixed prompt ("Summarize only grounded work…",personal_analyzer.rs build_fixed_prompt). agentsight's id_resolver keys sessions by(agent_name, pid, first user text), so the child PID lands in a new bucket → newsession_id; the prompt matched no internal-call marker inclassify_call_kind→call_kind=main→ the call passes the session list'scall_kind = 'main' OR NULLfilter and surfaces as a phantom 0-token session (#2750).What changed
src/agentsight/src/genai/helpers.rs: add the analyzer's stable prompt prefix (starts_with "Summarize only grounded work into the supplied JSON schema") to both classification paths —classify_call_kind(structured) andclassify_call_kind_from_raw(pending-write). Such calls now classify asrecap(the existing bucket for compaction/summary-style internal traffic) and stay out of the session list.main != recap), green after.Full root-cause chain with file:line references: issue comment.
Related issue
Refs #2750
Does not close it: the report also asks for merging analyzer calls into the parent session. That requires cross-process session injection (cosh-ng env passthrough or an agentsight merge strategy) and is proposed as a separate follow-up discussion in the issue comment. This PR implements layer ① (stop the session-list pollution); layer ② (parent-session attribution) is out of scope by design.
User / Agent impact
The 0-token "CoshNG" phantom sessions disappear from the dashboard session list and
/api/sessions. Analyzer events remain in the event store under their own session_id withcall_kind=recap.Risk and compatibility
Low risk: classification-only change behind a conservative
starts_withmarker tied to a fixed prompt string; the marker follows the existing best-effort pattern documented onclassify_call_kind. If cosh-ng ever changes that prompt, the call degrades back tomain(today's behavior), nothing breaks.Validation
On the ECS test machine (rustc/cargo 1.89.0, matching the repo toolchain):
cargo test -p agentsight --lib genai::helpers::tests— 71/71 pass (was 69 pass + 2 fail before the fix; the 2 failures are the new positive cases)cargo fmt --all -- --check— passcargo clippy -p agentsight --lib -- -D warnings— pass, zero warningsNote: the repo's CI "Test agentsight" job runs
@stable, which may differ from the pinned 1.89.0 toolchain used above; full-workspace tests were not run locally (agentsight compile weight) — targetedgenai::helperssuite covers this change.Documentation and rollback
No docs describe call-kind markers. Rollback: revert the single commit — classification reverts to today's behavior.