feat: text streaming improvements and CMU Maps integration #1
No reviewers
Labels
No labels
needs/docs
needs/research
needs/upstream
type/bug
type/external
type/feature
type/refactor
urgency
high
urgency
immediate
urgency
low
urgency
medium
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
ScottyLabs/cmugpt-agent!1
Loading…
Reference in a new issue
No description provided.
Delete branch "main"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
This PR adds CMU Maps support to the agent so the Surface can render a building or directions iframe alongside each response. It also includes small streaming and parser improvements to make tool-heavy answers feel more responsive.
Changes
CMU Maps integration
CmuMapsPydantic model onAgentResponsecarryingurl,mode("location"/"directions"), andtarget/src/destIDs + human labels. The Surface needs the matchingcmu_mapspayload handling to actually render the iframe (separate PR oncmugpt-surface).https://maps.scottylabs.org/{id}with either?dst={id}(location mode) or?src={src}&dst={dest}(directions mode); the Surface plugs that URL straight into an<iframe>. IDs and labels are kept as separate fields so the iframe header can show readable names ("Tepper School of Business") while the URL stays canonical.KNOWN_CMU_LOCATIONS) inagent_hub.pymaps shorter building names ("ghc","tepper","uc","mm", etc.) to canonical CMU Maps IDs. Matching is case-insensitive and word-boundary based, and the bare ID form ("GHC","MM") is also accepted directly when it appears in the query or in a tool result. Aliases are ordered longest-first so"hillman center"resolves before"hillman"and"gates hillman centers"wins over"gates". Queries for buildings outside this list will returncmu_maps.url = nulland fall back to plain text so no fabricated URL ever reaches the Surface._infer_cmu_mapsderives the payload deterministically from the user query and any tool invocations (maps_search_buildings,maps_get_path,maps_distance_between, …) rather than trusting the model.maps_get_path/maps_distance_between'sstart_idandend_idare used directly; (2) otherwise, parse"from X to Y"/"between X and Y"/"X from Y"patterns out of the query; (3) otherwise, look at building-search tool results for a"Name (ID)"match; (4) finally, fall back to"where is X"/"show me X"/"directions to X"patterns in the query. Returns an emptyCmuMaps(all fields null) if no rule fires._apply_cmu_maps_guardattaches the payload to responses and, when the model claims it couldn't find a location, OVERRIDESresponse_textwith canned success text plus the working URL. Failure claims are matched byMAP_FAILURE_CLAIM_RE(catches phrasings like "couldn't find", "wasn't able", "unable to retrieve", "didn't find the location", …). The replacement text comes from_cmu_maps_success_text, a numbered step list for directions, or a one-liner pointing at the building for single locations so the user sees a usable answer even when the model itself gave up.scottylabs.orgURL.Streaming
mapevent emitted before text starts streaming so the iframe can render immediately, before the first text delta.event: mapdocumented in the/agent/respond/streamdocstring.Parser robustness
_coerce_agent_responsesalvages the user-facingresponse_textwhen the model emits slightly malformed JSON (stray quotes, missing fields), so one bad token no longer kills a whole turn.Tests
test_cmu_maps_route_aliasesexercises the alias-resolution path end-to-end._infer_cmu_mapsand_cmu_maps_success_textso the maps inference logic is directly covered.