Skip to content

Conversation

@digitalsimboja
Copy link

@digitalsimboja digitalsimboja commented Sep 26, 2025

Fixes #6003

Relates to

Fixes runtime crash when getAgent() fails due to missing agents table or undefined character.id.

Risks

Low – affects only agent initialization during startup.

Background

AgentRuntime previously crashed if the agents table was missing or if no agent record was found. This PR ensures runtime startup by handling errors gracefully and creating the agent when necessary.

What does this PR do?

Wraps getAgent() in try/catch.

Falls back to createAgent() if no agent exists.

Logs clear error if character.id is missing.

Type of change

Bug fix – non-breaking, improves startup resilience.

Testing

Start runtime with a new Postgres DB (no agents table).

Start runtime with character config missing id.

Verify runtime does not crash and agent is created or error is logged clearly.


Note

Wrap ensureAgentExists lookup/update in try/catch with error logging; on failure or absence, proceed to create the agent.

  • Runtime (packages/core/src/runtime.ts)
    • ensureAgentExists:
      • Wrap existing agent lookup/update in try/catch and log errors.
      • Return updated agent on success with debug log.
      • On error or no existing agent, fall back to creating a new agent.

Written by Cursor Bugbot for commit 0aaaf69. This will update automatically on new commits. Configure here.

@graphite-app
Copy link

graphite-app bot commented Sep 26, 2025

How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • merge-queue - adds this PR to the back of the merge queue
  • merge-queue-hotfix - for urgent hot fixes, skip the queue and merge this PR next

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Sep 26, 2025

Important

Review skipped

Auto reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

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.

Unhandled exception when getAgents() fails in runtime.ts (missing agents table)

3 participants