Skip to content

feat: WebSocket notification when personality trimming activates #1064

@Aureliolo

Description

@Aureliolo

Context

PR #1059 implemented token-based personality trimming via PromptProfile.max_personality_tokens. During review, a personality_trimming_notify setting and WsEventType.PERSONALITY_TRIMMED enum were initially added but removed because no code consumed them -- they were dead scaffolding.

This issue tracks implementing the complete notification feature as a unit.

Scope

Setting

  • Add personality_trimming_notify setting in the ENGINE namespace (boolean, default true, yaml_path="engine.personality_trimming_notify")
  • Setting controls whether a WebSocket event is published when personality trimming activates

WebSocket event

  • Add WsEventType.PERSONALITY_TRIMMED = "personality.trimmed" enum member
  • Decide which WS channel to publish on (likely system or a new engine channel)
  • Add 'personality.trimmed' to frontend WsEventType in web/src/api/types.ts
  • If new channel: add to WS_CHANNELS in frontend types and subscribe in the WebSocket store

Publisher

  • In AgentEngine._prepare_context, after logging PROMPT_PERSONALITY_TRIMMED, read the personality_trimming_notify setting and publish a WsEvent when enabled
  • Payload: agent_id, agent_name, task_id, before_tokens, after_tokens, max_tokens, trim_tier, budget_met

Frontend (optional, can be separate issue)

  • Handle the event in the WebSocket store
  • Display a toast or notification when personality trimming occurs

Tests

  • Setting registration and defaults
  • Publisher emits event when setting is true
  • Publisher suppresses event when setting is false
  • Frontend type sync

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    prio:lowNice to have, can deferscope:smallLess than 1 day of worktype:featureNew feature implementationv0.6Minor version v0.6v0.6.3Patch release v0.6.3

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions