> For the complete documentation index, see [llms.txt](https://docs.xenoraa.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.xenoraa.com/xenoraa-release-notes/v10.x-releases/v10.0.7-xena-ai-improvements.md).

# v10.0.7 — Xena AI Improvements

## v10.0.7 — Xena AI Improvements: New Tools, Bug Fixes, Conversational UX

**Release Date**: 2026-07-10 **Commit**: `d60165c` **Type**: Feature + Bug Fix

***

### Summary

This release delivers 7 improvements to the Xena AI assistant: 2 critical P0 bug fixes, 3 new CRM tools, improved conversational UX (no more bracket templates), cross-session memory context, and better delete confirmation flow.

***

### Bug Fixes (P0)

**logAction() missing 4th arg** — `crmUpdateContact()` and `crmUpdateLead()` in `XenaActionService.php` were calling `logAction()` with only 3 arguments. The 4th `$success = true` was missing, causing PHP warnings and incorrect action log entries. Fixed.

**crm\_delete\_contact missing implementation** — The `crm_delete_contact` tool was referenced in the system prompt but had no backend implementation. Added `crmDeleteContact()` method in `XenaActionService` and the OpenAI function schema in `XenaController`.

***

### New Tools

| Tool                       | Description                                                                                                                                   |
| -------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------- |
| `crm_delete_contact`       | Deletes a contact by name or ID. Checks for soft-delete column (`deleted_at`) and uses it if available; falls back to hard delete.            |
| `crm_delete_lead`          | Deletes a lead by name or ID. Same soft/hard delete logic.                                                                                    |
| `crm_get_contact_by_phone` | Finds contacts by phone or mobile number using PostgreSQL `REGEXP_REPLACE` for digit-only matching. Returns up to 5 matches with action card. |

***

### System Prompt Rules

**DELETE CONFIRMATION RULE** — Xena must first confirm before deleting any record (show the name, ask "Shall I permanently delete this?"). Once the user says "yes", "confirm", "proceed", "go ahead", or any affirmative, Xena calls the delete tool immediately — it does NOT search again or ask for confirmation a second time.

**CONVERSATIONAL FIELD COLLECTION RULE** — When the user says "create a contact" or "add a lead" without providing any details, Xena asks for required fields one at a time (name → phone → email) instead of showing a `[bracket]` template.

**TYPO TOLERANCE RULE** — Xena is tolerant of typos and casual spelling, inferring intent from context.

**TEMPLATE RULE** — Xena never responds with bracket templates. It always asks conversationally or calls a tool directly.

***

### Cross-Session Context Injection

The last 3 successful actions from `xena_action_logs` are now injected into the system prompt as a "RECENT ACTIONS (last session context)" block. This allows Xena to understand references like "the one I just created" or "that contact" across different chat sessions.

***

### UI Enhancements

Thinking steps (e.g., "Finding contact...", "Deleting contact...", "Contact deleted!"), suggestion chips, and action card case handlers were added for all 3 new tools.

***

### Files Changed

| File                                 | Changes                                                                                                                                                           |
| ------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `app/Services/XenaActionService.php` | Fixed logAction() 4th arg in crmUpdateContact/crmUpdateLead; added crmDeleteContact(), crmDeleteLead(), crmGetContactByPhone() methods; added 3 tools to tool map |
| `app/Services/XenaController.php`    | Added OpenAI function schemas for 3 new tools; thinking steps; suggestion chips; case handlers; system prompt rules; cross-session context injection              |


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.xenoraa.com/xenoraa-release-notes/v10.x-releases/v10.0.7-xena-ai-improvements.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
