Skip to content

feat: add relationship-aware NPC society scheduling#108

Merged
JOY (JOY) merged 1 commit into
devfrom
codex/npc-society-llm
May 21, 2026
Merged

feat: add relationship-aware NPC society scheduling#108
JOY (JOY) merged 1 commit into
devfrom
codex/npc-society-llm

Conversation

@JOY
Copy link
Copy Markdown
Contributor

Summary

  • Add relationship-aware NPC society scheduling so proactive ticks can choose eligible nearby NPCs without replaying stale player-chat events.
  • Add relationship ledger context and anti-repeat guidance to the DOS.AI decision prompt payload.
  • Extend Nakama runtime tests for relationship-aware prompts, forbidden repeat lines, and proactive scheduler decisions.

Local review

  • code-review skill fallback: APPROVED. No blocking findings after fixing the talk_frequency=0 defaulting edge case.

Tests

  • npm install
  • npm run build
  • npm test
  • git diff --check
  • em-dash scan on changed files

@JOY
Copy link
Copy Markdown
Contributor Author

Codex (@codex) review

@chatgpt-codex-connector
Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@JOY JOY (JOY) merged commit 6b0c5ed into dev May 21, 2026
1 check passed
@JOY JOY (JOY) deleted the codex/npc-society-llm branch May 21, 2026 00:25
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: 3006301c4b

ℹ️ 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".

id: "society-decision-proactive-" + sanitizeNakamaIdentifier(profile.actor_id, "npc") + "-" + (index + 1),
actor_id: profile.actor_id,
display_name: profile.display_name,
trigger_event_id: "proactive-" + sanitizeNakamaIdentifier(playerActorId, "nearby-player"),
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 Generate unique proactive trigger_event_id per schedule tick

Using a fixed trigger_event_id of proactive-<player> for every proactive decision makes all future proactive schedules for that player map to the same conversation session key (createOrUpdateConversationSession derives session_id from trigger_event_id when no explicit session id is passed). After that session reaches max_turns and becomes closed, later proactive ticks keep reusing the closed session, so new proactive exchanges inherit stale transcript/objective state instead of starting fresh.

Useful? React with 👍 / 👎.

Comment on lines +3560 to +3562
function shouldBuildProactiveSocietyQueue(request: any): boolean {
return trimString(request.mode) === "proactive" ||
trimString(request.nearby_player_actor_id || request.player_actor_id) !== "";
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Respect trigger_event_id when deciding proactive fallback

The queue now appends proactive candidates whenever a player actor id is present, even in reactive requests that explicitly set trigger_event_id. This bypasses the event filter and can return decisions unrelated to the requested event replay, which breaks deterministic processing for callers that expect trigger_event_id to strictly scope scheduling.

Useful? React with 👍 / 👎.

agent_context: compactAgentDecisionContext(context),
knowledge_packs: buildDecisionKnowledgePacks(nk, context, world),
conversation_session: buildDecisionConversationSession(nk, ownerId, world),
anti_repeat: buildDecisionAntiRepeatContext(nk, ownerId, world),
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Include anti_repeat in DOS.AI token budget estimation

The prompt now sends an extra anti_repeat block, but the budget gate still uses estimateDosAiDecisionTokens without accounting for this added payload. In environments with tighter DOS_AI_DECISION_DAILY_TOKEN_BUDGET and larger recent speech/session history, requests can be admitted after the intended cap should have been reached, weakening cost and rate-limit controls.

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