Skip to content

fix: directions_tool turn-by-turn instructions never populated - #256

Open
mattpodwysocki wants to merge 1 commit into
mainfrom
fix/directions-turn-by-turn-instructions
Open

fix: directions_tool turn-by-turn instructions never populated#256
mattpodwysocki wants to merge 1 commit into
mainfrom
fix/directions-turn-by-turn-instructions

Conversation

@mattpodwysocki

Copy link
Copy Markdown
Contributor

Summary

directions_tool has always requested steps=true and documented its response as including "turn-by-turn instructions," but the extraction code read announcements from step.voiceInstructions — a field the Directions API only populates when the separate voice_instructions=true parameter is set, which this tool never sends. So the instructions field was silently empty for every single call, short or long route alike.

Fix: switch to step.maneuver.instruction — a human-readable instruction string (e.g. "Bear right onto Great Portland Street/A4201. Continue on A4201.") already present on every step whenever steps=true is set, no extra parameter needed.

Also raised the output cap from 10 to 200. The old cap was calibrated for the old (broken) source, where a single turn could emit several verbose voice announcements. maneuver.instruction is one entry per real turn, so a normal route — even a long one with dozens of turns — comfortably fits under the new cap; the old cap of 10 would have excluded instructions for almost any real multi-turn route once the underlying bug was fixed.

Spun out of review discussion on #255.

Test plan

  • npx vitest run — all 939 tests pass, including updated/new coverage in cleanResponseData.test.ts (real extraction shape, a step with no instruction, a realistic 40-turn route, and the new 200-instruction cap)
  • npm run build succeeds, lint clean
  • Live-verified against the real Directions API: a real San Francisco route now returns 8 real turn-by-turn instructions (e.g. "Drive northeast on Market Street.", "Turn right onto 10th Street.") where it previously returned none
  • CHANGELOG.md updated

🤖 Generated with Claude Code

The tool has always requested steps=true and documented its response as
including "turn-by-turn instructions", but the extraction read
step.voiceInstructions, which the Directions API only returns when the
separate voice_instructions=true parameter is set -- never sent by this
tool. So `instructions` was silently empty for every call.

Switched to step.maneuver.instruction, a human-readable instruction
string already present on every step whenever steps=true is set, no
extra parameter needed. Raised the output cap from 10 to 200: the old cap
was sized for the old source (which could emit several announcements per
turn), while maneuver.instruction is one entry per real turn, so a normal
route -- even a long one with dozens of turns -- stays well under it.

Confirmed live against the real Directions API.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@mattpodwysocki
mattpodwysocki requested a review from a team as a code owner August 27, 2026 13:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant