Skip to content

feat: harden knowledge pack prompt traces#181

Merged
JOY (JOY) merged 1 commit into
devfrom
codex/knowledge-prompttrace
May 23, 2026
Merged

feat: harden knowledge pack prompt traces#181
JOY (JOY) merged 1 commit into
devfrom
codex/knowledge-prompttrace

Conversation

@JOY
Copy link
Copy Markdown
Contributor

Summary

  • replace fixed KnowledgePack selection with bounded scored selection from zone, profession, faction, quest, rumor, explicit world pack ids, and semantic player/objective keywords
  • record redacted PromptTrace metadata for selected pack ids, missing pack ids, context scores, conversation objective id, and identity version
  • extend Unity PromptTrace DTO and HUD summary to show top context scores and missing packs
  • update architecture, roadmap, and AI NPC roadmap docs

Closes #136.

Local verification

  • npm.cmd ci
  • npm.cmd run build
  • npm.cmd test
  • npx.cmd markdownlint-cli2 "CHANGELOG.md" "ROADMAP.md" "docs/ARCHITECTURE.md" "docs/design/37-ai-npc-backend-client-roadmap.md"
  • git diff --check
  • rg -n "—|–" changed code/docs

Local code review

APPROVED. Nakama still owns LLM context selection and PromptTrace persistence. Unity only reads redacted metadata for debug display. No provider keys, raw prompts, or authoritative game-state mutations were added.

Unity note

Unity C# compile smoke will be run from the root project after merge because the active Editor is opened on the root worktree, not this feature worktree.

@JOY JOY (JOY) merged commit 2fc4db7 into dev May 23, 2026
2 checks passed
@JOY JOY (JOY) deleted the codex/knowledge-prompttrace branch May 23, 2026 11:55
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: cd2ac3026b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "Codex (@codex) review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "Codex (@codex) address that feedback".

Comment on lines +6953 to +6956
for (var index = 0; index < values.length; index += 1) {
var value = values[index];
appendKnowledgePackCandidate(candidates, trimString(value && value.id) || trimString(value), baseScore, reason);
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Cap world-supplied KnowledgePack candidates

rpcAgentDecideUnsafe accepts world_snapshot directly from the request payload, and this loop appends every entry from world.knowledge_pack_ids/context_pack_ids/knowledge_packs with no upper bound; later buildDecisionKnowledgePackSelection calls readKnowledgePack for every candidate and sorts the full list. A client can send a very large array to force unbounded storage reads and CPU work in a single decision RPC, which can degrade latency or exhaust server capacity. Add a strict per-request cap (and ideally reject/trim over-limit payloads) before candidates are appended/read.

Useful? React with 👍 / 👎.

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