Skip to content

fix: convert dict to KernelSnapshot in kernel state endpoint#31

Merged
nmlemus merged 7 commits intomainfrom
fix/kernel-state-dict-conversion
Jan 29, 2026
Merged

fix: convert dict to KernelSnapshot in kernel state endpoint#31
nmlemus merged 7 commits intomainfrom
fix/kernel-state-dict-conversion

Conversation

@nmlemus
Copy link
Owner

@nmlemus nmlemus commented Jan 29, 2026

Problem

The GET /api/sessions/{session_id}/kernel endpoint was returning a 500 Internal Server Error:

{"detail": "Error getting kernel state: 'dict' object has no attribute 'variables'"}

Root Cause

The get_kernel_state() method in ConversationalAgent returns a Dict[str, Any], but the _snapshot_to_response() function expected a KernelSnapshot object and tried to access .variables as an attribute.

Solution

Added type checking and conversion logic to handle both cases:

  • If a dict is returned, convert it to a KernelSnapshot object
  • If a KernelSnapshot is already returned, use it directly

Testing

  • Tested the endpoint manually and confirmed it now returns the kernel state correctly

The get_kernel_state method in ConversationalAgent returns a dict,
but _snapshot_to_response expected a KernelSnapshot object. Added
type checking and conversion logic to handle both cases.

Fixes: 500 error on GET /api/sessions/{id}/kernel
These directories contained outdated code that no longer works
with the current codebase:
- demo/financial-mcp: old MCP demo
- examples/: old usage examples and run outputs
Adds GitHub Actions workflow with multiple security tools:
- Bandit: Python code security analysis
- pip-audit: Dependency vulnerability scanning
- Gitleaks: Secret detection
- Trivy: Docker container security scanning
- OSSF Scorecard: Repository security best practices

Results are uploaded to GitHub Security tab.
- Use --exit-zero for Bandit to ensure SARIF file is always created
- Update all upload-sarif actions from v3 to v4
- Add file existence check before uploading SARIF files
@github-advanced-security
Copy link

This pull request sets up GitHub code scanning for this repository. Once the scans have completed and the checks have passed, the analysis results for this pull request branch will appear on this overview. Once you merge this pull request, the 'Security' tab will show more code scanning analysis results (for example, for the default branch). Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results. For more information about GitHub code scanning, check out the documentation.

- Update scikit-learn>=1.5.0 to fix CVE PYSEC-2024-110 (TfidfVectorizer data leakage)
- Add --skip-editable to pip-audit to skip local package not yet on PyPI
@nmlemus nmlemus merged commit c7f7975 into main Jan 29, 2026
10 checks passed
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