Skip to content

fix: pass SessionModel to get_suggestions instead of raw dict#125

Merged
RichardAtCT merged 2 commits intoRichardAtCT:mainfrom
haripatel07:fix/quick-actions-session-data-arg
Mar 4, 2026
Merged

fix: pass SessionModel to get_suggestions instead of raw dict#125
RichardAtCT merged 2 commits intoRichardAtCT:mainfrom
haripatel07:fix/quick-actions-session-data-arg

Conversation

@haripatel07
Copy link
Copy Markdown
Contributor

Description

Fixes the /actions command crash reported in #119.

QuickActionManager.get_suggestions() expects a SessionModel object but
was being called with session_data=dict — a keyword argument that doesn't
exist in the method signature, causing a TypeError every time a user ran /actions.

Fix

Construct a minimal SessionModel from available handler context
(user_id and current_dir) and pass it correctly as session=.

Related Issue

Fixes #119

Type of Change

  • Bug fix

Testing

  • 435 passed, 0 failed
  • No regressions

Checklist

  • Code follows project style guidelines
  • Self-review completed
  • No breaking changes

Fixes RichardAtCT#119 - QuickActionManager.get_suggestions() was being called with
session_data=dict but the method signature expects session=SessionModel.
Construct a minimal SessionModel from the available handler context
(user_id and current_dir) to satisfy the interface correctly.
Copilot AI review requested due to automatic review settings March 4, 2026 06:22
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 the /actions command crash by aligning the QuickActionManager.get_suggestions() call site with its actual signature (expects a SessionModel, not a session_data dict).

Changes:

  • Replace session_data=... call with session=SessionModel(...) when requesting quick action suggestions.
  • Add required imports (SessionModel, datetime/timezone) to support session construction.

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

Comment on lines +1103 to +1109
actions = await quick_action_manager.get_suggestions(
session_data={"working_directory": str(current_dir), "user_id": user_id}
session=SessionModel(
session_id="",
user_id=user_id,
project_path=str(current_dir),
created_at=datetime.now(timezone.utc),
last_used=datetime.now(timezone.utc),
Copy link

Copilot AI Mar 4, 2026

Choose a reason for hiding this comment

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

QuickActionManager._analyze_context() accesses session.context, but SessionModel (from src/storage/models.py) doesn't define a context field. As constructed here, this will raise AttributeError inside get_suggestions() and it will fall back to returning [], so /actions will always show “No Actions Available”. Consider attaching a context attribute (e.g., {} or recent message context) to the SessionModel instance before calling get_suggestions, or adjust the quick actions feature to use getattr(session, "context", None) instead of session.context.

Copilot uses AI. Check for mistakes.
Comment on lines +1108 to +1110
created_at=datetime.now(timezone.utc),
last_used=datetime.now(timezone.utc),
)
Copy link

Copilot AI Mar 4, 2026

Choose a reason for hiding this comment

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

created_at and last_used are computed with two separate datetime.now(...) calls. It’s clearer (and avoids subtle ordering differences) to compute now once and reuse it for both fields.

Copilot uses AI. Check for mistakes.
Comment on lines 1112 to 1113


Copy link

Copilot AI Mar 4, 2026

Choose a reason for hiding this comment

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

There’s trailing whitespace on this blank line, which can cause noisy diffs and may fail strict linters. Remove the extra spaces so the line is empty.

Suggested change

Copilot uses AI. Check for mistakes.
@FridayOpenClawBot
Copy link
Copy Markdown

Friday's Review 🖤

Fix is correct and well-targeted. The root cause — passing a non-existent session_data= kwarg with a raw dict — is properly addressed by constructing a SessionModel and using the correct session= parameter.

Observations

Trailing whitespace (line ~1115): The diff shows a line with only spaces (+ ) after the closing paren. Minor, but worth cleaning up.

datetime.now(timezone.utc) called twice: created_at and last_used are set with separate datetime.now() calls — they'll be microseconds apart. Consider capturing once:

now = datetime.now(timezone.utc)
session=SessionModel(
    session_id="",
    user_id=user_id,
    project_path=str(current_dir),
    created_at=now,
    last_used=now,
)

session_id="": The empty string is a reasonable placeholder for an ephemeral/context-only session, but if SessionModel validation ever tightens (e.g. requires a non-empty ID), this could break. Worth a comment like # ephemeral session for quick actions context or using a generated ID if the model supports it.

Summary

Solid fix. The two datetime.now() calls and the empty session_id are minor nits rather than blockers. Tests passing at 435/0 is reassuring.

Friday, AI assistant to @RichardAtCT

Copy link
Copy Markdown
Owner

@RichardAtCT RichardAtCT left a comment

Choose a reason for hiding this comment

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

LGTM — fixes the SessionModel constructor argument for get_suggestions. Closes #119.

@RichardAtCT RichardAtCT merged commit 3a01ce9 into RichardAtCT:main Mar 4, 2026
1 check failed
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.

QuickActionManager.get_suggestions() got an unexpected keyword argument 'session_data'

4 participants