Skip to content

fix: use clean user message for auto-title instead of skill-bloated input - #4946

Open
dieutx wants to merge 1 commit into
NousResearch:mainfrom
dieutx:fix/auto-title-use-clean-user-message
Open

fix: use clean user message for auto-title instead of skill-bloated input#4946
dieutx wants to merge 1 commit into
NousResearch:mainfrom
dieutx:fix/auto-title-use-clean-user-message

Conversation

@dieutx

@dieutx dieutx commented Apr 4, 2026

Copy link
Copy Markdown
Contributor

Summary

Sessions started via skill invocation get meaningless auto-generated titles like "Skill Invocation and Content Loading" instead of the user's actual intent. Follow-up to #4940 which fixed the same issue for memory providers.

Root Cause

When a skill is active, the `message` variable contains the full skill activation payload: a `[SYSTEM: The user has invoked...]` prefix, the entire SKILL.md content (often 1K+ chars), and only then the user's actual instruction. Both `cli.py:6186` and `gateway/run.py:6031` pass this bloated `message` to `maybe_auto_title()`. The title generator truncates to 500 chars (`title_generator.py:29`), so it only sees skill boilerplate.

`run_conversation()` already computes `original_user_message` (line 6516) — the clean user input without skill injection. PR #4940 used it for memory providers with this exact comment:

Use original_user_message (clean input) — user_message may contain injected skill content that bloats / breaks provider queries.

But `original_user_message` was never added to the result dict, so callers couldn't access it.

Fix

  1. run_agent.py: Added `original_user_message` to the result dict
  2. cli.py: `result.get("original_user_message") or message`
  3. gateway/run.py: Same pattern

Tests

4 tests: result dict includes original message, clean message preferred over bloated, fallback to raw message when missing, clean input fits within 500-char truncation.

```
4 passed
```

@dieutx
dieutx force-pushed the fix/auto-title-use-clean-user-message branch from fbc971c to 3bb6a4d Compare April 15, 2026 14:15
@dieutx

dieutx commented Apr 15, 2026

Copy link
Copy Markdown
Contributor Author

Rebased this onto current main.\n\nLocal: pytest -q tests/test_auto_title_clean_message.py -> 4 passed

@dieutx
dieutx force-pushed the fix/auto-title-use-clean-user-message branch from 3bb6a4d to 227c68b Compare April 15, 2026 14:18
@alt-glitch alt-glitch added type/bug Something isn't working comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint comp/cli CLI entry point, hermes_cli/, setup wizard comp/gateway Gateway runner, session dispatch, delivery P3 Low — cosmetic, nice to have labels May 1, 2026

@teknium1 teknium1 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for targeting a real title-quality problem: current main still passes the expanded message at cli.py:12558 and gateway/run.py:19030.

Problems

  • The proposed original_user_message is not intrinsically clean. It is persist_user_message only when provided, otherwise the model-facing user_message (agent/turn_context.py:304; PR base run_agent.py:7925). Normal CLI skill invocation queues the expanded payload (cli.py:9037-9044) and only supplies that override for voice mode (cli.py:12319-12346), so the PR would still title from skill scaffolding.
  • The added tests only construct local dicts and repeat the fallback expression; they never exercise either title caller with a skill-expanded message.
  • The proposed result-dict hunk has moved: current result assembly is agent/turn_finalizer.py:399-428, following refactor 053025238434cfbf121873977b39888d7f27d1c1.

Suggested changes

  • Use the existing extract_user_instruction_from_skill_message() (agent/skill_commands.py:58-112) at the title boundary and add CLI/gateway regression tests that assert maybe_auto_title receives the extracted instruction. Decide explicitly how a bare skill invocation should title, since the extractor returns None for that case.

Automated hermes-sweeper review.

Comment thread run_agent.py
"partial": False, # True only when stopped due to invalid tool calls
"interrupted": interrupted,
"response_previewed": getattr(self, "_response_was_previewed", False),
"original_user_message": original_user_message,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

original_user_message is not guaranteed to be clean skill input: the turn setup defines it as persist_user_message only when supplied, otherwise the model-facing user_message (current agent/turn_context.py:304; PR base run_agent.py:7925). Normal CLI and gateway skill paths pass the expanded payload without that override, so this field would still contain the skill body. Use the canonical skill-instruction extractor before title generation instead.

@teknium1 teknium1 added sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform labels Jul 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint comp/cli CLI entry point, hermes_cli/, setup wizard comp/gateway Gateway runner, session dispatch, delivery P3 Low — cosmetic, nice to have sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants