agentmemory icon indicating copy to clipboard operation
agentmemory copied to clipboard

fix: preserve session start metadata

Open EvanWangZ opened this issue 6 months ago • 2 comments

Summary

  • accept optional title, summary, and firstPrompt in POST /agentmemory/session/start
  • use title as the fallback session label/first prompt so OpenCode-created sessions do not surface as raw IDs when prompt submission races session creation
  • keep explicit summary and firstPrompt values distinct when clients provide both
  • document the optional session labels in the API table

Fixes #244

Related

  • This is intentionally scoped to #244. #306 touches the same endpoint for #259 agent/session attribution metadata, but does not handle the OpenCode title -> summary/firstPrompt path. Happy to rebase if #306 lands first.

Tests

  • npm run build
  • npm test
  • npm test -- test/api-session-start.test.ts

EvanWangZ avatar May 13 '26 02:05 EvanWangZ

@Zavianx is attempting to deploy a commit to the rohitg00's projects Team on Vercel.

A member of the Team first needs to authorize it.

vercel[bot] avatar May 13 '26 02:05 vercel[bot]

📝 Walkthrough

Walkthrough

The PR extends the session creation endpoint to accept and persist optional human-readable labels (title, summary, firstPrompt) provided in the request body. A helper function normalizes and truncates these strings; summary and firstPrompt default to the title value when omitted. The endpoint behavior, test coverage, and API documentation are all updated together.

Changes

Session Label Initialization

Layer / File(s) Summary
Preview helper and request contract
src/triggers/api.ts
asSessionPreview(value, maxLength) normalizes whitespace and truncates strings; the api::session::start request body type now includes optional title, summary, and firstPrompt fields.
Session label computation and assignment
src/triggers/api.ts
When creating a session, each label is converted to a truncated preview. summary and firstPrompt fall back to the title preview when not explicitly provided; both are assigned to the session only if non-empty.
Documentation and test coverage
README.md, test/api-session-start.test.ts
README API table documents the three new optional fields; test suite verifies that omitting summary and firstPrompt causes them to inherit from title, and that explicit values are preserved in both response body and KV-persisted session.

🎯 2 (Simple) | ⏱️ ~12 minutes

🐰 Sessions now wear their names with pride,
No more IDs to hide or misguide,
From title springs summary and prompt so fine,
All three labels dance in perfect design! ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title 'fix: preserve session start metadata' is concise and directly relates to the main change: accepting and preserving optional session metadata (title, summary, firstPrompt) in the POST /agentmemory/session/start endpoint.
Linked Issues check ✅ Passed The pull request fully addresses issue #244: api::session::start now reads and stores body.title as both summary and firstPrompt, resolving the raw ID display issue and race condition mentioned in the issue.
Out of Scope Changes check ✅ Passed All changes are directly scoped to issue #244: README documentation updates, API handler modifications to accept/process metadata fields, and comprehensive test coverage for the new functionality.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • [ ] Create PR with unit tests

[!TIP]

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

coderabbitai[bot] avatar May 13 '26 02:05 coderabbitai[bot]