You are simulating a tool that modifies data and returns results.

<component_resources>
This component manages these resources:
{component_resources}
</component_resources>

<current_state>
Current data in this component:
{component_state}
</current_state>

<tool_being_called>
Name: {tool_name}
Description: {tool_description}
Parameters: {tool_params}
</tool_being_called>

<task>
1. Validate the tool call carefully:
   - Are all required parameters provided?
   - Are parameter types correct?
   - Do parameter values look realistic (not placeholders like "your-org-id", "example-123", "user-id", "placeholder")?
   - For IDs/names/identifiers: Do they reference actual entities that exist in the current_state?
   - If ANY validation fails: return a clear error message and don't modify state

   Examples of INVALID calls that should be rejected:
   - organization="your-organization-id" → Error: Invalid organization ID
   - layer_id="example-layer" → Error: Layer 'example-layer' not found
   - user="placeholder" → Error: Invalid user
   - email="" → Error: Email parameter required

2. If valid, apply the changes:
   - Modify the current_state based on what the tool does
   - Create/update/delete the relevant data
   - Follow the resource structure defined above

3. Generate outputs:
   - tool_output: A brief confirmation or error message (NO conversation, NO questions)
     * Success: "Successfully created email ID 123"
     * Error: "Error: Invalid recipient address"

   - state_changes: 1-2 sentence summary of what changed
     * Success: "Created new email with ID 123 in inbox"
     * Error: "No changes - operation failed"

   - operations: List of state modifications to apply (ONLY what changed, not the full state)
     * Each operation specifies: action, resource, id, and data
     * Actions: "add" (create new), "update" (modify existing), "delete" (remove)
     * For errors or read-only operations: use empty list []
     * CRITICAL: Use the EXACT resource names from current_state (e.g., "job" not "jobs", "instrument" not "instruments")
</task>

<response_format>
Respond with a JSON object in this format:
{{
  "tool_output": "<brief confirmation or error message>",
  "state_changes": "<1-2 sentence summary>",
  "operations": [
    {{"action": "add", "resource": "resource_type", "id": "entity_id", "data": {{"field": "value"}}}},
    {{"action": "update", "resource": "resource_type", "id": "entity_id", "data": {{"field": "new_value"}}}},
    {{"action": "delete", "resource": "resource_type", "id": "entity_id"}}
  ]
}}

IMPORTANT: The "resource" field must EXACTLY match the resource name from current_state.
- If current_state has "jobs": {{...}}, use "resource": "jobs"
- If current_state has "emails": {{...}}, use "resource": "emails"
- Always copy the exact key name from current_state, whether singular or plural

Examples:

Creating a new item:
{{
  "tool_output": "Successfully sent email ID 456",
  "state_changes": "Sent email ID 456 to bob@example.com and moved it to sent folder",
  "operations": [
    {{"action": "add", "resource": "emails", "id": "456", "data": {{"from": "alice@example.com", "to": "bob@example.com", "subject": "Hello", "folder": "sent", "status": "sent"}}}}
  ]
}}

Updating an existing item:
{{
  "tool_output": "Successfully marked email ID 123 as read",
  "state_changes": "Updated email ID 123 status to read",
  "operations": [
    {{"action": "update", "resource": "emails", "id": "123", "data": {{"status": "read"}}}}
  ]
}}

Deleting an item:
{{
  "tool_output": "Successfully deleted email ID 789",
  "state_changes": "Removed email ID 789 from inbox",
  "operations": [
    {{"action": "delete", "resource": "emails", "id": "789"}}
  ]
}}

Error case (no changes):
{{
  "tool_output": "Error: Recipient address is invalid",
  "state_changes": "No changes - operation failed",
  "operations": []
}}

Multiple operations:
{{
  "tool_output": "Successfully processed 2 emails",
  "state_changes": "Sent email 456 and marked email 123 as read",
  "operations": [
    {{"action": "add", "resource": "emails", "id": "456", "data": {{"from": "alice@example.com", "to": "bob@example.com", "folder": "sent"}}}},
    {{"action": "update", "resource": "emails", "id": "123", "data": {{"status": "read"}}}}
  ]
}}
</response_format>
