Skip to content

fix(sight): classify analyzer calls as internal - #2755

Merged
chengshuyi merged 1 commit into
mainfrom
fix/sight/analyzer-call-kind
Aug 22, 2026
Merged

fix(sight): classify analyzer calls as internal#2755
chengshuyi merged 1 commit into
mainfrom
fix/sight/analyzer-call-kind

Conversation

@jfeng18

@jfeng18 jfeng18 commented Aug 21, 2026

Copy link
Copy Markdown
Collaborator

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 → new session_id; the prompt matched no internal-call marker in classify_call_kindcall_kind=main → the call passes the session list's call_kind = 'main' OR NULL filter 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) and classify_call_kind_from_raw (pending-write). Such calls now classify as recap (the existing bucket for compaction/summary-style internal traffic) and stay out of the session list.
  • Discriminating tests for both paths: the exact prefix classifies as recap; similar-but-different summarize wording stays main. Verified red-on-unpatched before the fix (both new positive cases failed with 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 with call_kind=recap.

Risk and compatibility

  • Public CLI, API, configuration, or documented behavior changed
  • Privileged or security-sensitive behavior changed
  • Cross-component contract changed
  • Migration or rollback guidance is needed

Low risk: classification-only change behind a conservative starts_with marker tied to a fixed prompt string; the marker follows the existing best-effort pattern documented on classify_call_kind. If cosh-ng ever changes that prompt, the call degrades back to main (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 — pass
  • cargo clippy -p agentsight --lib -- -D warnings — pass, zero warnings

Note: 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) — targeted genai::helpers suite covers this change.

Documentation and rollback

No docs describe call-kind markers. Rollback: revert the single commit — classification reverts to today's behavior.

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>

@qoderai qoderai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

本次审查范围内未发现需要修改的问题。


🤖 Generated by QoderView workflow run

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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".

Comment thread src/agentsight/src/genai/helpers.rs

@chengshuyi chengshuyi left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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.

@chengshuyi
chengshuyi merged commit da18b76 into main Aug 22, 2026
29 checks passed
@chengshuyi
chengshuyi deleted the fix/sight/analyzer-call-kind branch August 22, 2026 10:48
@Daydreamer-Li Daydreamer-Li mentioned this pull request Aug 22, 2026
9 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component:sight src/agentsight/

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants