Skip to content

feat: persist NPC conversation turns#104

Merged
JOY (JOY) merged 1 commit into
devfrom
codex/conversation-memory
May 20, 2026
Merged

feat: persist NPC conversation turns#104
JOY (JOY) merged 1 commit into
devfrom
codex/conversation-memory

Conversation

@JOY
Copy link
Copy Markdown
Contributor

Summary

  • Add secondspawn_npc_conversation_get so clients and debug tools can inspect an active NPC conversation session.
  • Persist compact recent_turns on conversation sessions, including the triggering player line and each NPC reply.
  • Let follow-up player chat events reuse an existing conversation_session_id instead of creating a fresh stateless session every message.
  • Include recent_turns in the DOS.AI decision prompt conversation context.
  • Update Unity chat routing to remember the active session and pass it on follow-up chat messages.

Why

NPC chat was model-backed and session-aware, but follow-up player messages could still create fresh sessions. This makes a 1:1 chat behave more like an RPG conversation: the NPC can see what was just said and clients can inspect the session state.

Safety

  • The model still receives read-only context only.
  • LLM output still goes through the existing validated intent path.
  • Unity sends only session identifiers and player text. No provider keys or model credentials are exposed.

Local Code Review Fallback

Verdict: APPROVED.

TDD Evidence

  • RED: test expected 26 registered RPCs plus session recent_turns and failed because secondspawn_npc_conversation_get did not exist.
  • GREEN: new tests pass after adding the RPC, session turn persistence, follow-up session reuse, and prompt context injection.

Verification

  • npm.cmd install in backend/nakama
  • npm.cmd run build in backend/nakama
  • npm.cmd test in backend/nakama
  • git diff --check --cached
  • Staged-file em-dash scan

Verification Note

Unity C# compile still needs Editor/root-checkout verification because isolated worktrees do not contain Unity Library package assemblies. The Unity changes are DTO string fields plus session-id routing in the existing chat script.

Unrelated Files Left Out

The generated knowledge-pack file was touched by npm run build line endings only and was intentionally not staged.

@JOY JOY (JOY) merged commit 86c62e0 into dev May 20, 2026
1 check passed
@JOY JOY (JOY) deleted the codex/conversation-memory branch May 20, 2026 19:12
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.

1 participant