HKUDS/Vibe-Trading · error · ValueError

unknown section '{name}'; valid: {', '.join(_ALL_SECTIONS)}

Error message

unknown section '{name}'; valid: {', '.join(_ALL_SECTIONS)}

What it means

The stock_profile tool resolves a `sections` argument against a fixed set of known section names (_SECTION_MODULES keys). Each requested name is normalized (strip+lowercase) and must match a known section; unknown names raise ValueError listing all valid sections. This prevents loading nonexistent profile sections.

Source

Thrown at agent/src/tools/stock_profile_tool.py:220

def _resolve_sections(sections: Optional[List[str]]) -> List[str]:
    """Validate the requested sections, defaulting to all when omitted.

    Args:
        sections: Requested section names, or ``None`` for every section.

    Returns:
        An ordered, de-duplicated list of valid section names.

    Raises:
        ValueError: If any requested name is not a supported section.
    """
    if not sections:
        return list(_ALL_SECTIONS)
    resolved: List[str] = []
    for name in sections:
        key = str(name).strip().lower()
        if key not in _SECTION_MODULES:
            raise ValueError(
                f"unknown section '{name}'; valid: {', '.join(_ALL_SECTIONS)}"
            )
        if key not in resolved:
            resolved.append(key)
    return resolved


def _market_for(ticker: str) -> str:
    """Classify a ticker into a coarse market label for the envelope."""
    return "hk" if ticker.strip().upper().endswith(".HK") else "us"


class StockProfileTool(BaseTool):
    """Company profile: key stats, analyst estimates, and ownership."""

    name = "get_stock_profile"
    description = (
        "Fetch a read-only company profile for a US or Hong Kong listing from "

View on GitHub (pinned to 80ffdda44c)

Solutions

  1. Read the error message: it enumerates every valid section; use only those names
  2. Update the tool package if you expect a section that the installed version doesn't register
  3. Remove or correct the offending entry in the sections list

Example fix

# before
tool.execute(symbol="AAPL", sections=["valuaton"])
# after
tool.execute(symbol="AAPL", sections=["valuation"])  # use a name from the error's valid list
Defensive patterns

Strategy: validation

Validate before calling

from agent.src.tools.stock_profile_tool import _ALL_SECTIONS
sections = [s for s in requested if str(s).strip().lower() in set(_ALL_SECTIONS)]
if not sections:
    sections = list(_ALL_SECTIONS)
tool.execute(symbol=symbol, sections=sections)

Type guard

def valid_section(name: str) -> bool:
    return str(name).strip().lower() in _ALL_SECTIONS

Prevention

When it happens

Trigger: Calling stock_profile with sections=["overview", "fundamentals"] where one name isn't in _ALL_SECTIONS; typos like "valuaton"; names not in the module registry despite being mentioned in docs of a different version.

Common situations: Docs/tool-schema drift between versions where a section was renamed or removed; agents hallucinating section names; casing/spelling mistakes (these are auto-lowercased, but wrong words still fail).

Related errors


AI-assisted analysis of HKUDS/Vibe-Trading@80ffdda44c (2026-08-28). Data as JSON: /api/errors/390e636283fde118. Report an issue: GitHub.