Skip to content

Add user location setting injected into system prompt #97

Description

@cmac86

Description

Add a user location setting (city + region/state) that gets injected into the system prompt context at session start, similar to how timezone is injected today.

Why

Many tools benefit from knowing the user's location without requiring the user to specify it every time:

  • Weather — "what's the current weather" should default to the user's city
  • Time zones — already handled via timezone setting
  • Restaurant/POI searches — "find me a pizza place" needs location context
  • News — local news queries
  • Event search — "what's happening tonight"

This came up in discussion #89 where a user noticed the new qwen3.5-9b model is stricter about required parameters and no longer infers defaults from tool description text. The cleanest fix is to give the model actual location context rather than relying on per-tool hacks.

Implementation

Settings

  • New setting: user_location (string, e.g. "Dallas, Texas")
  • Default: empty
  • UI: text input in Settings → Agent tab (alongside agent name, timezone, etc.)

Prompt injection

In src/caal/settings.pyload_prompt_with_context(), add location to the context block alongside the existing date/time injection. Example for English:

context_parts = [
    f"Today is {format_date_speech_friendly(now, language=language)}.",
    f"The current time is {format_time_speech_friendly(now, language=language)} {timezone_display}.",
]
if user_location:
    context_parts.append(f"The user is located in {user_location}.")
date_context = " ".join(context_parts)

Add equivalent translations for fr, it, pt, da, ro.

Template placeholder

Add {{USER_LOCATION}} to the prompt template so power users can position it explicitly in prompt/custom.md if they want finer control.

Benefits

  • Tool authors don't need to repeat location defaults in every tool description
  • Works across all tools — weather, maps, local search, news, events
  • Cleaner n8n workflows — no need for {{ $json.location || 'Dallas, Texas' }} fallbacks in every workflow
  • Respects the design principle — it's a small, predictable addition to context rather than a new tool surface

Out of scope (for now)

  • Automatic location detection (IP geolocation, browser geolocation)
  • Multiple location profiles (home vs work vs travel)
  • Radius/proximity parameters

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions