fix(memory): unify Outcome enum and add ABANDONED support
- Add ABANDONED value to core Outcome enum in types.py - Replace duplicate OutcomeType class in mcp/tools.py with alias to Outcome - Simplify mcp/service.py to use outcome directly (no more silent mapping) - Add migration 0006 to extend PostgreSQL episode_outcome enum - Add missing constraints to migration 0005 (ix_facts_unique_triple_global) This fixes the semantic issue where ABANDONED outcomes were silently converted to FAILURE, losing information about task abandonment. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1024,15 +1024,8 @@ class MemoryToolService:
|
||||
context: ToolContext,
|
||||
) -> dict[str, Any]:
|
||||
"""Execute the 'record_outcome' tool."""
|
||||
# Map outcome type to memory Outcome
|
||||
# Note: ABANDONED maps to FAILURE since core Outcome doesn't have ABANDONED
|
||||
outcome_map = {
|
||||
OutcomeType.SUCCESS: Outcome.SUCCESS,
|
||||
OutcomeType.PARTIAL: Outcome.PARTIAL,
|
||||
OutcomeType.FAILURE: Outcome.FAILURE,
|
||||
OutcomeType.ABANDONED: Outcome.FAILURE, # No ABANDONED in core enum
|
||||
}
|
||||
outcome = outcome_map.get(args.outcome, Outcome.FAILURE)
|
||||
# OutcomeType is now an alias for Outcome, use directly
|
||||
outcome = args.outcome
|
||||
|
||||
# Record in episodic memory
|
||||
episodic = await self._get_episodic()
|
||||
|
||||
@@ -12,6 +12,9 @@ from typing import Any
|
||||
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
# OutcomeType alias - uses core Outcome enum from types module for consistency
|
||||
from app.services.memory.types import Outcome as OutcomeType
|
||||
|
||||
|
||||
class MemoryType(str, Enum):
|
||||
"""Types of memory for storage operations."""
|
||||
@@ -32,15 +35,6 @@ class AnalysisType(str, Enum):
|
||||
LEARNING_PROGRESS = "learning_progress"
|
||||
|
||||
|
||||
class OutcomeType(str, Enum):
|
||||
"""Outcome types for record_outcome tool."""
|
||||
|
||||
SUCCESS = "success"
|
||||
PARTIAL = "partial"
|
||||
FAILURE = "failure"
|
||||
ABANDONED = "abandoned"
|
||||
|
||||
|
||||
# ============================================================================
|
||||
# Tool Argument Schemas (Pydantic models for validation)
|
||||
# ============================================================================
|
||||
|
||||
@@ -42,6 +42,7 @@ class Outcome(str, Enum):
|
||||
SUCCESS = "success"
|
||||
FAILURE = "failure"
|
||||
PARTIAL = "partial"
|
||||
ABANDONED = "abandoned"
|
||||
|
||||
|
||||
class ConsolidationStatus(str, Enum):
|
||||
|
||||
Reference in New Issue
Block a user