Rpatel/create session on claude#1222
Merged
rushilpatel0 merged 5 commits intodevelopfrom Aug 19, 2025
Merged
Conversation
codegen-team
approved these changes
Aug 19, 2025
Codecov Report❌ Patch coverage is
|
|
|
||
| # Proactively create the backend session as a fallback in case hooks fail | ||
| try: | ||
| agent_run_id = create_claude_session(session_id, resolved_org_id) |
Contributor
There was a problem hiding this comment.
Logic error: Potential duplicate session creation leading to multiple agent runs
The proactive create_claude_session call runs before hooks are installed, but the SessionStart hook also creates the session. This can cause duplicate sessions or noisy errors if the backend isn’t strictly idempotent on session_id.
Suggested change
| agent_run_id = create_claude_session(session_id, resolved_org_id) | |
| # Set up Claude hook for session tracking first | |
| hook_ready = ensure_claude_hook() | |
| if not hook_ready: | |
| console.print("⚠️ Failed to set up session tracking hook", style="yellow") | |
| # Fallback: proactively create the backend session only if hooks failed | |
| try: | |
| agent_run_id = create_claude_session(session_id, resolved_org_id) | |
| if agent_run_id: | |
| console.print("✅ Backend session created", style="green") | |
| else: | |
| console.print("⚠️ Could not create backend session at startup (will rely on hooks)", style="yellow") | |
| except Exception as e: | |
| console.print(f"⚠️ Session creation error at startup: {e}", style="yellow") |
This preserves your fallback while avoiding duplicate creation when hooks succeed.
Contributor
|
Found 0 critical and 1 important issue. Please review my inline comment above. 🔍 View my analysis: https://codegen.com/agent/trace/77640 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
Content
Testing
Please check the following before marking your PR as ready for review