Skip to content

fixed annoying error, when starting up the assistant with jobs = true#184

Open
sproft wants to merge 1 commit intodnhkng:mainfrom
sproft:main
Open

fixed annoying error, when starting up the assistant with jobs = true#184
sproft wants to merge 1 commit intodnhkng:mainfrom
sproft:main

Conversation

@sproft
Copy link
Copy Markdown

@sproft sproft commented Mar 15, 2026

because hassattr evaluated to true when self.autonomy_loop = None

Summary by CodeRabbit

  • Bug Fixes
    • Enhanced system stability by fixing a condition that ensures the emotion agent only connects to the autonomy loop when it is properly initialized and available.

Copilot AI review requested due to automatic review settings March 15, 2026 17:28
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 15, 2026

📝 Walkthrough

Walkthrough

A single conditional check in the autonomy loop wiring logic is refactored from a presence check (hasattr) to a truthiness check, ensuring the emotion agent is only connected when the autonomy loop is not only present but also a truthy value.

Changes

Cohort / File(s) Summary
Autonomy Loop Wiring Guard
src/glados/core/engine.py
Changed condition from hasattr(self, "autonomy_loop") to self.autonomy_loop: to verify the autonomy loop exists and is truthy before wiring the emotion agent, preventing operations on falsy/None values.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

🐰 A loop once checked just for its name,
Now verified it holds real flame—
No phantom threads, no echoes faint,
The wiring works, no more complaint! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title relates to the main change but is informal and not fully descriptive; it mentions fixing an error during startup with jobs=true but lacks technical clarity about what was fixed.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
📝 Coding Plan
  • Generate coding plan for human review comments

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.

Tip

CodeRabbit can use your project's `pylint` configuration to improve the quality of Python code reviews.

Add a pylint configuration file to your project to customize how CodeRabbit runs pylint.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes a startup crash in the core engine when autonomy jobs are enabled by preventing an attempt to call methods on a None autonomy loop during subagent registration.

Changes:

  • Replace hasattr(self, "autonomy_loop") with a truthiness check on self.autonomy_loop before wiring the emotion agent.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +713 to 714
if self.autonomy_config.enabled and self.autonomy_loop:
self.autonomy_loop.set_emotion_agent(emotion_agent)
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/glados/core/engine.py`:
- Around line 713-714: The call to set_emotion_agent in _register_subagents() is
skipped because self.autonomy_loop is not yet created; either move the wiring to
after the autonomy_loop is instantiated or implement a pending-attach mechanism:
when _register_subagents() sees autonomy_config.enabled but autonomy_loop is
None, save emotion_agent to self._pending_emotion_agent (or similar), and ensure
the code that creates/assigns self.autonomy_loop (where the loop is constructed)
checks for self._pending_emotion_agent and calls
self.autonomy_loop.set_emotion_agent(self._pending_emotion_agent) (then clear
the pending field). This preserves the existing autonomy_config.enabled check,
uses the existing symbols (_register_subagents, autonomy_loop,
set_emotion_agent, emotion_agent), and guarantees emotion wiring regardless of
init order.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: b42b7503-d17a-428a-80bd-2d714da780b6

📥 Commits

Reviewing files that changed from the base of the PR and between 353b6f3 and d543a40.

📒 Files selected for processing (1)
  • src/glados/core/engine.py

Comment on lines +713 to 714
if self.autonomy_config.enabled and self.autonomy_loop:
self.autonomy_loop.set_emotion_agent(emotion_agent)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Emotion agent wiring now never happens due init order

At Line 713, self.autonomy_loop is always None when _register_subagents() runs (the loop is only created later at Line 511), so set_emotion_agent(...) is skipped permanently. This fixes the startup error, but it also silently disables vision→emotion forwarding.

Suggested fix
@@
-        # Wire emotion agent to autonomy loop for vision events
-        if self.autonomy_config.enabled and self.autonomy_loop:
-            self.autonomy_loop.set_emotion_agent(emotion_agent)
+        # Autonomy loop is initialized later in __init__; wiring is done there.
@@
         if self.autonomy_config.enabled:
             assert self.autonomy_event_bus is not None
             assert self.autonomy_slots is not None
             self.autonomy_loop = AutonomyLoop(
@@
                 pause_time=self.PAUSE_TIME,
             )
+            if self._emotion_agent is not None:
+                self.autonomy_loop.set_emotion_agent(self._emotion_agent)
             if not self.vision_config:
                 self.autonomy_ticker_thread = threading.Thread(
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/glados/core/engine.py` around lines 713 - 714, The call to
set_emotion_agent in _register_subagents() is skipped because self.autonomy_loop
is not yet created; either move the wiring to after the autonomy_loop is
instantiated or implement a pending-attach mechanism: when _register_subagents()
sees autonomy_config.enabled but autonomy_loop is None, save emotion_agent to
self._pending_emotion_agent (or similar), and ensure the code that
creates/assigns self.autonomy_loop (where the loop is constructed) checks for
self._pending_emotion_agent and calls
self.autonomy_loop.set_emotion_agent(self._pending_emotion_agent) (then clear
the pending field). This preserves the existing autonomy_config.enabled check,
uses the existing symbols (_register_subagents, autonomy_loop,
set_emotion_agent, emotion_agent), and guarantees emotion wiring regardless of
init order.

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.

2 participants