> ## Documentation Index
> Fetch the complete documentation index at: https://docs.agno.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Decision Logs: Recording Outcomes

> The feedback half of the decision log: log_decision records the choice with its reasoning, and record_outcome closes the loop later with what actually happened.

The feedback half of the decision log: log\_decision records the choice with its reasoning, and record\_outcome closes the loop later with what actually happened. Decision logging is AGENTIC-only - the agent logs deliberately; there is no automatic extraction pass.

```python record_outcomes.py theme={null}
"""
Decision Logs: Recording Outcomes
=================================
The feedback half of the decision log: log_decision records the choice with
its reasoning, and record_outcome closes the loop later with what actually
happened. Decision logging is AGENTIC-only - the agent logs deliberately;
there is no automatic extraction pass.

Run:
    .venvs/demo/bin/python cookbook/08_learning/09_decision_logs/02_record_outcomes.py
"""

from agno.agent import Agent
from agno.db.postgres import PostgresDb
from agno.learn import DecisionLogConfig, LearningMachine
from agno.models.openai import OpenAIResponses

# ---------------------------------------------------------------------------
# Create Agent
# ---------------------------------------------------------------------------

db = PostgresDb(db_url="postgresql+psycopg://ai:ai@localhost:5532/ai")

agent = Agent(
    id="outcome-logger",
    name="Outcome Logger",
    model=OpenAIResponses(id="gpt-5.5"),
    db=db,
    learning=LearningMachine(
        decision_log=DecisionLogConfig(),
    ),
    instructions=[
        "You are an engineering advisor.",
        "When you make a recommendation, log it as a decision with your reasoning.",
        "When told how a past recommendation worked out: first call "
        "search_decisions to find that decision and its id, then call "
        "record_outcome with that id. Never ask the user for a decision id.",
    ],
    markdown=True,
)

# ---------------------------------------------------------------------------
# Run Demo
# ---------------------------------------------------------------------------

if __name__ == "__main__":
    agent.print_response(
        "Should we use Postgres or DynamoDB for the new billing service? "
        "We need transactions and our team knows SQL.",
        session_id="s1",
        stream=True,
    )

    agent.print_response(
        "Update: we went with your Postgres recommendation and the migration "
        "went smoothly. Record that outcome.",
        session_id="s2",
        stream=True,
    )

    print("\n--- the decision log, with its outcome ---")
    agent.learning_machine.decision_log_store.print(agent_id="outcome-logger")
```

## Run the Example

<Steps>
  <Snippet file="create-venv-step.mdx" />

  <Step title="Install dependencies">
    ```bash theme={null}
    uv pip install -U agno "psycopg[binary]" openai sqlalchemy
    ```
  </Step>

  <Step title="Export your OpenAI API key">
    <CodeGroup>
      ```bash Mac/Linux theme={null}
      export OPENAI_API_KEY="your_openai_api_key_here"
      ```

      ```bash Windows theme={null}
      $Env:OPENAI_API_KEY="your_openai_api_key_here"
      ```
    </CodeGroup>
  </Step>

  <Snippet file="run-pgvector-step.mdx" />

  <Step title="Run the example">
    Save the code above as `record_outcomes.py`, then run:

    ```bash theme={null}
    python record_outcomes.py
    ```
  </Step>
</Steps>

Full source: [cookbook/08\_learning/09\_decision\_logs/02\_record\_outcomes.py](https://github.com/agno-agi/agno/blob/v3.0.4/cookbook/08_learning/09_decision_logs/02_record_outcomes.py)
