-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Closed
Description
Goose FOREIGN KEY Constraint Failed Bug
Summary
When using Goose SDK programmatically with Synagoose Generator, sessions fail with "FOREIGN KEY constraint failed" (code: 787) after LLM response is received.
Environment
- Goose commit: a48fd4d (latest main)
- OS: macOS 25.3.0
- Provider: Groq (llama-3.3-70b-versatile)
- Configuration: GOOSE_DISABLE_KEYRING=true, GROQ_API_KEY from secrets.yaml
Reproduction Steps
- Create temporary session with SessionManager:
let temp_dir = std::env::temp_dir().join(format!("test_{}", uuid::Uuid::new_v4()));
std::fs::create_dir_all(&temp_dir)?;
let session_manager = SessionManager::new(temp_dir.clone());
let session = session_manager.create_session(
temp_dir.clone(),
format!("test_{}", uuid::Uuid::new_v4()),
SessionType::Hidden,
).await?;- Create agent with Groq provider:
std::env::set_var("GOOSE_DISABLE_KEYRING", "true");
std::env::set_var("GOOSE_PROVIDER", "groq");
std::env::set_var("GOOSE_MODEL", "llama-3.3-70b-versatile");
let provider = create_with_named_model("groq", "llama-3.3-70b-versatile").await?;
let agent = Agent::new();
agent.update_provider(provider, &session.id).await;- Send message and await response:
let message = Message::user().with_text("Say hello");
let config = SessionConfig {
id: session.id.clone(),
schedule_id: None,
max_turns: Some(1),
retry_config: None,
};
let mut stream = agent.reply(message, config, None).await?;
// Collect response...Expected Behavior
LLM response is saved to session database successfully.
Actual Behavior
error[SG2011]: server error 0
= what: LLM API server returned an error
= why: Server-side issue (status 0): Failed to execute Agent reply: error returned from database: (code: 787) FOREIGN KEY constraint failed
= fix: This is a temporary server problem. The request will be retried automatically.
Observations
- LLM call SUCCEEDS - takes 35+ seconds, returns valid response
- Error occurs AFTER response received, during database save
- Issue persists with single-threaded test execution
- Clearing temp directories doesn't resolve issue
- Code 787 = SQLite FOREIGN KEY constraint violation
Impact
- Blocks integration testing with real LLM providers
- Affects Synagoose-core and any SDK consumer using programmatic sessions
Workaround Attempted
- ✅ Cleaned up temp session directories
- ✅ Single-threaded execution (--test-threads=1)
- ❌ No successful workaround found
Related Commits
Possibly related to:
- Added transaction commits to multi sql functions in session_manager #5693: "Added transaction commits to multi sql functions in session_manager"
- feat(goose-acp): enable parallel sessions with isolated agent state #6392: "feat(goose-acp): enable parallel sessions with isolated agent state"
Full Error Context
The error comes from Goose's session database after LLM provider returns successfully. This suggests a schema mismatch or missing parent record for a foreign key relationship in the session messages table.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels