Skip to content

Fix /clear command, places JSON parsing, stale AI prices, agent silent failures#171

Merged
asim merged 2 commits intomainfrom
copilot/remove-clear-button-command
Mar 2, 2026
Merged

Fix /clear command, places JSON parsing, stale AI prices, agent silent failures#171
asim merged 2 commits intomainfrom
copilot/remove-clear-button-command

Conversation

Copy link
Contributor

Copilot AI commented Mar 2, 2026

The clear history button was unusable on mobile, the agent quoted stale training prices even when live data was fetched, and the places search always failed silently when called via the agent.

Chat: replace clear button with /clear command

  • Removed <a id="chat-clear"> from the chat template
  • Intercept /clear in askLLM() before the fetch, call clearChatHistory() client-side

AI system prompt: current date + live data framing

  • Injects time.Now() as Today's date is … so the model has temporal grounding
  • Relabels RAG context block from "Recent context" → "Current context (live market data…)"
  • Explicit instruction: "For prices: the data provided in context is current and live — quote it directly as the current price"

Places: fix JSON body parsing for agent tool calls

handleSearch/handleNearby read params via r.ParseForm() only. api.ExecuteTool sends a JSON body, so params were always empty → 400 → agent showed "unavailable". Extracted a shared helper:

func parseRequestParams(r *http.Request) func(string) string {
    r.ParseForm()
    var jsonBody map[string]interface{}
    if app.SendsJSON(r) {
        json.NewDecoder(r.Body).Decode(&jsonBody)
    }
    return func(key string) string {
        if v := r.Form.Get(key); v != "" { return v }
        if jsonBody != nil { if v, ok := jsonBody[key]; ok { return fmt.Sprintf("%v", v) } }
        return ""
    }
}

Both handlers now call parseRequestParams(r), handling both form (web UI) and JSON (agent/API).

Agent: log tool failures + stronger synthesiser prompt

  • Tool errors are now logged with name, error, and truncated response body
  • Synthesiser system prompt strengthened to explicitly forbid falling back to training data for prices/weather: "Do NOT use your training knowledge for current prices or live data — it will be outdated"

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

… AI prompt improvements

Co-authored-by: asim <17530+asim@users.noreply.github.com>
Copilot AI changed the title [WIP] Remove clear history button and switch to /clear command Fix /clear command, places JSON parsing, stale AI prices, agent silent failures Mar 2, 2026
Copilot finished work on behalf of asim March 2, 2026 17:27
@asim asim marked this pull request as ready for review March 2, 2026 17:34
@asim asim merged commit 62246ae into main Mar 2, 2026
@asim asim deleted the copilot/remove-clear-button-command branch March 2, 2026 21:05
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