---
description: Log this working session to Grounded
argument-hint: [optional note on what to emphasise]
allowed-tools: Bash(curl:*), Bash(jq:*)
---
Log this working session to Grounded. $ARGUMENTS

Grounded answers over HTTP at `$GROUNDED_URL` (default `http://127.0.0.1:7437`). If `GROUNDED_TOKEN` is set, the API wants `Authorization: Bearer $GROUNDED_TOKEN`; with no token configured the header is ignored.

Log a session only because the user asked, or because the working session is ending. Finishing one request is not the end of a session.

1. Draft it:
   - `summary`: one line, what shipped. This is the line the next agent sees at startup; stay under 250 characters.
   - `details`: what changed, what was decided, what is still open, and where the work lives (repo, branch, files). Recall searches this.
   - `project`: the project this work was for. `agent`: who you are. `machine`: optional. `tags`: optional list of strings.

2. Write it:

```bash
jq -n --arg s '<summary>' --arg d '<details>' --arg p '<project>' --arg a '<agent>' \
  '{summary: $s, details: $d, project: $p, agent: $a}' |
  curl -s -X POST "${GROUNDED_URL:-http://127.0.0.1:7437}/sessions" \
    -H 'content-type: application/json' \
    -H "authorization: Bearer ${GROUNDED_TOKEN:-}" \
    --data-binary @-
```

3. Read the reply. A `budget` object means the summary is longer than its share of the brief: shorten it with `PATCH /sessions/<id>`. A 400 names the cap and how much to trim. To correct a session later, `PATCH /sessions/<id>` rather than logging a second, contradicting one.

Report the session's `typedId`. If a call fails, read `GET /llms.txt` on the same base URL.
