Skip to content

fix(agent): handle whitespace-only input in build_plan_path - #9102

Closed
Tranquil-Flow wants to merge 1 commit into
NousResearch:mainfrom
Tranquil-Flow:fix/build-plan-path-whitespace
Closed

fix(agent): handle whitespace-only input in build_plan_path#9102
Tranquil-Flow wants to merge 1 commit into
NousResearch:mainfrom
Tranquil-Flow:fix/build-plan-path-whitespace

Conversation

@Tranquil-Flow

Copy link
Copy Markdown
Contributor

What changed and why

build_plan_path() crashes with IndexError when user_instruction is whitespace-only (e.g. " \n "), because .strip().splitlines() returns an empty list and [0] is applied to it.

The fix splits the chained expression into two lines, guarding against the empty list before indexing.

Changes

  • agent/skill_commands.py: Guard empty splitlines() result, falling back to default "conversation-plan" slug
  • tests/agent/test_skill_commands.py: Added 3 regression tests for whitespace-only, empty string, and tab-only input

How to test

from agent.skill_commands import build_plan_path
# All should return paths containing "conversation-plan" without raising IndexError:
build_plan_path("   \n   ")
build_plan_path("")
build_plan_path("\t\t")
# Normal input still works:
build_plan_path("Build a web scraper")  # contains "build-a-web-scraper"
pytest tests/agent/test_skill_commands.py::TestPlanSkillHelpers -v

Platform tested

  • macOS (Darwin 24.6.0, Python 3.14)

Closes #7576

Guard against empty splitlines() result when user_instruction
contains only whitespace, falling back to the default
"conversation-plan" slug instead of raising IndexError.

Closes NousResearch#7576
@alt-glitch alt-glitch added type/bug Something isn't working P3 Low — cosmetic, nice to have comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint tool/skills Skills system (list, view, manage) labels Apr 27, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Prior attempts at this fix: #7692, #7474, #7613 (all closed). Closes #7576.

@teknium1

Copy link
Copy Markdown
Contributor

Thanks for the careful fix and regression tests, @Tranquil-Flow! Unfortunately this PR is no longer applicable.

build_plan_path() was entirely removed from agent/skill_commands.py in commit b2e124d (merged Apr 24 2026, PR #15047 — "refactor(commands): drop /provider, /plan handler, and clean up slash registry"). The /plan special handler was replaced by plain skill dispatch, deleting the function and its surrounding _PLAN_SLUG_RE pattern along with 535 lines of related code, tests, and docs across 20 files.

  • The symbol build_plan_path does not exist anywhere on current main
  • The associated test file (tests/agent/test_skill_commands.py) also had its plan-related tests removed in the same commit
  • The bug this PR addresses (the IndexError on empty splitlines()) no longer exists because the code path is gone

Closing as the underlying code has been removed. This is an automated hermes-sweeper review.

@teknium1 teknium1 closed this Apr 28, 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 P3 Low — cosmetic, nice to have tool/skills Skills system (list, view, manage) type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: IndexError in build_plan_path on whitespace-only input

3 participants