feat: unblock agent workflow — pager-free help + subtype narrowing#61
Merged
feat: unblock agent workflow — pager-free help + subtype narrowing#61
Conversation
…wing
Agents running `python -c "import wkls; help(wkls)"` get stuck on
the terminal pager. Three changes unblock that workflow:
1. wkls.help() prints the guide without touching the pager — same
content as the module docstring, just via print(). Surfaced in
dir(wkls) so agents discover it via introspection. Omitted from
__all__ to avoid polluting 'from wkls import *'.
2. When an AmbiguousLocationError spans multiple subtypes (e.g.
.search('san diego') returns both the city and the county), the
error now suggests .cities() / .counties() alongside by_id(). The
narrower is the method, not the subtype attribute — dot access is
still admin-hierarchy only.
3. Multi-row result-mode Wkl's dir() advertises the listing methods
(cities, counties, regions, countries, dependencies, subtypes) so
the subtype-filter path shows up in auto-complete / introspection,
not just in docs.
Module docstring updated to lead with wkls.help() and list subtype
narrowing as option (a) in the ambiguity section.
26607cc to
5e0ed70
Compare
`uv build` was packaging the working directory's `.venv-1.0.1/` into the source distribution because .gitignore's `.venv` pattern only matched the exact name, not suffixed variants. That tripped the sdist unpack step on restricted files inside jedi's bundled typeshed. Broaden the ignore pattern to `.venv-*` and add explicit hatch sdist excludes as a belt-and-suspenders guard for any non-VCS packaging path — plus the untracked `test_nb.ipynb` and `docs/` that shouldn't ship in wheels either.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
From an agent session (Copilot, terminal shell, local install):
Agent wasted ~8 commands escaping the terminal pager that
help(wkls)opens. Then spent another ~10 commands oninspect.signature+dir(Wkl)to reverse-engineer the API. Finally ran.search('san diego').wkt(), hitAmbiguousLocationError, and jumped toby_id('<uuid>')from the error message — never discovering that.search('san diego').cities().wkt()is a faster path.What
Three changes unblock the agent workflow without rewriting anything:
wkls.help()— prints the module docstring to stdout. Same content ashelp(wkls)but no pager. Listed indir(wkls)so agents find it. Intentionally omitted from__all__to avoid pollutingfrom wkls import *.AmbiguousLocationErrorsuggests subtype narrowers when candidates span multiple subtypes. E.g. for San Diego (city + county), the error now emits.cities()/.counties()alongsideby_id(...). Suppressed when narrowing wouldn't reduce the set (e.g. all 18 Franklin townships in PA are localities —.cities()wouldn't help, so it isn't suggested).dir()advertises the listing methods (cities,counties,regions,countries,dependencies,subtypes). Previously only inspection verbs (count,head, etc.) showed up — so agents never saw the subtype-filter path unless they read the docstring.Module docstring updated to lead with
wkls.help()and list subtype narrowing as option (a) under "Resolving ambiguity".Also includes a small unrelated build fix: broader
.venv-*ignore + explicit hatch sdist excludes souv builddoesn't pick up local virtualenvs ortest_nb.ipynb.Test plan
uv run pytest— 151 passed, 2 xfailed (added 3 tests: pager-free help, subtype suggestion fires, subtype suggestion suppressed when redundant)wkls.us.ca.search('san diego').cities().wkt()returns a valid WKTdir(wkls)includeshelp;dir(wkls.us.ca.search('san diego'))includescities,counties, etc.uv buildsucceeds with a 35-file sdist (no.venv-*/ notebooks)Follow-ups (not in this PR)
Scoped out to keep this PR focused on the agent-trap we set out to fix. Tracked from a Copilot usability review + an ecosystem survey in
docs/investigations/llm-friendly-library-patterns.md:.head(n)/.limit(n)should return aWkl, not a raw sedona DataFrame. Agents naturally chain.head(3).to_dicts()and it fails because.to_dicts()is aWklmethod, not a DataFrame method. Fix is ~10 LOC — wrap the sliced DataFrame in a result-modeWkl.Did you mean '<X>'?on unknown chain attributes.wkls.us.ca.sanfransiscoshould suggestsanfranciscoviadifflib.get_close_matches. Python 3.10+ ships this forNameError/AttributeError; we'd mirror that convention for chain misses. ~20 LOC.by_id.docs/llms.txt— short index file following the Answer.AI convention (adopted by Pydantic AI, Anthropic docs, Stripe, Cloudflare). Pointers to README + per-feature markdown sections, not inline docs. Near-zero maintenance.