Adapt upstream enhancements: ACS 1-year hint (#145) + token flattening (#144)#2
Merged
Merged
Conversation
…au#144 (token flattening) Incorporates two upstream enhancements from uscensusbureau/us-census-bureau-data-api-mcp, adapted to this fork's existing response-shape and error machinery rather than applied verbatim. uscensusbureau#145 -- ACS 1-year population threshold: - buildApiErrorMessage now detects acs/acs1 datasets and, on a 400, leads with the 65,000-population-threshold explanation and an acs/acs5 suggestion before the generic discovery-tool guidance. Folded into our existing helper instead of upstream's standalone inline branch. - Tool description gains a concise threshold note, consistent with our caveats-led description style. uscensusbureau#144 -- token management: - fetch-dataset-geography now emits compact JSON (drops the 2-space indent), the one tool still returning pretty-printed JSON. resolve-geography-fips and search-data-tables already exceed uscensusbureau#144's goal via response-format.ts, so the upstream content-flattener helper is intentionally not vendored. Adds a unit test for the ACS-1yr 400 path. typecheck clean; affected unit suites (35 tests) pass. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
Incorporates two enhancements from upstream uscensusbureau/us-census-bureau-data-api-mcp, adapted to this fork's existing response-shape and error machinery rather than applied verbatim. Upstream's
#145is stacked on#144, so both arrive together.uscensusbureau#145 — ACS 1-year population threshold (upstream PR)
ACS 1-year estimates only exist for areas of 65,000+ people; smaller areas return a bare
400with no explanation — a common source of confusion for the model.buildApiErrorMessagenow detectsacs/acs1datasets and, on a400, leads with the threshold explanation + anacs/acs5suggestion before the generic discovery-tool guidance. Folded into our existing error helper instead of upstream's standalone inline branch.acs/acs1(upstream also matched bareacs1, which risks false positives).uscensusbureau#144 — token management (upstream PR)
Upstream replaces pretty-printed JSON (
JSON.stringify(data, null, 2)) with compact output to save ~30–40% of response tokens — relevant to our token-constrained 4o/Copilot consumer.response-format.tsalready replaced pretty-printed JSON inresolve-geography-fipsandsearch-data-tableswith numbered Record blocks, which exceeds feat: add content flattener for improved token management uscensusbureau/us-census-bureau-data-api-mcp#144's goal — left unchanged.fetch-dataset-geographywas the only tool still emitting indented JSON; switched to compact. Its payload (ParsedGeographyEntry[]) contains none of the fields upstream's flattener strips, so the standalonecontent-flattener.tshelper is intentionally not vendored (it would add a competing abstraction for zero extra benefit here).Testing
tsc --noEmitclean.400path.🤖 Generated with Claude Code