Skip to content

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

Merged
mattpodwysocki merged 3 commits into
mainfrom
fix/directions-turn-by-turn-instructions
Oct 28, 2026
Merged

mattpodwysocki merged 3 commits into
mainfrom
fix/directions-turn-by-turn-instructions

Conversation

@mattpodwysocki

@mattpodwysocki mattpodwysocki commented Aug 27, 2026 •

Copy link
Copy Markdown
Contributor

Summary

directions_tool has always requested steps=true and says it returns turn-by-turn instructions, but instructions has been empty on every call.

Cause: the code read step.voiceInstructions, which the Directions API only fills in when voice_instructions=true is sent. We never send it.

Fix:

  • Read step.maneuver.instruction instead, a readable sentence on every step whenever steps=true (for example "Turn right onto 10th Street."). No extra API parameter.
  • Raise the cap from 10 to 200 instructions. The old cap was sized for voice announcements, several per turn. maneuver.instruction is one per turn, so even a long route with dozens of turns fits, and a cap of 10 would have cut off almost every real route.

Spun out of review on #255.

Updated after #296 and #298 merged

Main was merged in. The only conflict was in cleanResponseData.test.ts: this PR's new expectations against main's typed routesOf() helper, so the tests now use that helper and pass the CI typecheck. The CHANGELOG entry moved under Unreleased with its PR number.

Testing

  • cleanResponseData.test.ts covers the real step shape, a step with no instruction, a 40-turn route and the 200 cap.
  • Typecheck clean, build OK, 97 files / 1085 tests pass, lint 0 errors. CI green.
  • Live against the real Directions API (before the main merge): a San Francisco route returned 8 real instructions ("Drive northeast on Market Street.", "Turn right onto 10th Street.", ...) where it returned none before.

🤖 Generated with Claude Code

@mattpodwysocki
mattpodwysocki requested a review from a team as a code owner August 27, 2026 13:42
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 force-pushed the fix/directions-turn-by-turn-instructions branch from e63176d to 9018d4f Compare October 1, 2026 14:51
…y-turn-instructions

# Conflicts:
#	test/tools/directions-tool/cleanResponseData.test.ts
Comment on lines +287 to +293
// Process steps if they exist to collect turn-by-turn instructions.
// `maneuver.instruction` (e.g. "Bear right onto Great Portland
// Street/A4201") is present on every step whenever steps=true is
// requested, unlike `step.voiceInstructions`, which requires the
// separate voice_instructions=true parameter -- never sent by this
// tool, so that field was always empty and `instructions` never
// actually populated.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NIT: this seems like a comment documenting history, not functionality

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair, rewrote it to describe what the code does (4b20de5).

Comment on lines +317 to +322
// One instruction per real maneuver (unlike the old voice-announcement
// source, which could repeat several announcements per turn), so a
// normal route -- even a long one with dozens of turns -- stays well
// within a generous cap. The cap here is just a backstop against a
// pathological case (e.g. many waypoints each with a complex urban leg),
// not a limit expected to bite in practice.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as previous comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, fixed in 4b20de5.

From review on #256.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@mattpodwysocki
mattpodwysocki merged commit b8bb32d into main Oct 28, 2026
5 checks passed
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.

2 participants