# Agents

## Agents in Dataiku

Dataiku Agent Hub provides a framework for building and deploying conversational AI agents that can reason over data, call tools, and take actions within a Dataiku project. Agents are powered by large language models and can be connected to a set of tools - including semantic models, dataset lookups, Python functions, knowledge bases, and visual send actions - that allow them to retrieve information, perform computations, and interact with external systems. Each agent is configured with a system prompt that defines its role, behaviour, and the rules it must follow. Tools are registered to the agent and called automatically when the agent determines they are needed to answer a user query. The agent maintains conversational context across turns, enabling multi-step workflows where the output of one tool call informs the next. Dataiku agents support human-in-the-loop controls - the agent can surface a draft or a proposed action and wait for explicit user confirmation before proceeding. This is particularly important in regulated industries where automated actions such as sending communications or logging activity records must be approved by a human before execution. For more information on building agents in Dataiku refer to the [Dataiku Agent Hub documentation](https://www.dataiku.com/stories/blog/introducing-agent-hub).


## NBA Action Assistant

The NBA Action Assistant is the conversational AI agent included in this solution. It is designed for pharmaceutical sales representatives and marketing operations teams and supports the full weekly HCP engagement cycle - from finding the right HCPs and understanding why they were recommended, to drafting personalised outreach, checking compliance, sending approved communications, and logging activity to CRM. The agent uses a single-agent architecture with six tools to simplify routing, eliminate ambiguity between sub-agents, and reduce the risk of hallucinated SQL queries by replacing free-form query generation with pre-validated semantic model lookups.

**Tools:**

| Tool | Type | Purpose |
|---|---|---|
| `query_hcps` | Semantic Model | Filtered and ranked HCP lists |
| `get_hcp_snapshot` | Dataset Lookup | Single HCP full record by name or ID |
| `explain_nba` | Python | Parses AI justification into structured sections |
| `send_email` | Send Message | Sends drafted email after user confirmation |
| `create_crm_record` | Python | Generates Veeva-aligned CRM activity record |
| `pharma_doc_KB` | Knowledge Base | Answers compliance and product questions via RAG |

**Key design decisions:**

- Semantic models replace SQL query tools — the agent filters and retrieves data through pre-validated metrics rather than generating raw queries, eliminating column hallucination and invalid join errors
- `get_hcp_snapshot` resolves HCP names to IDs at the start of any HCP-specific workflow — the ID is retained for the remainder of the conversation so the user is never asked to re-provide information already retrieved
- `send_email` always requires explicit YES confirmation before execution - no email is sent without a human-in-the-loop approval step
- `pharma_doc_KB` is a RAG knowledge base built on KindPharma's Promotional Communication Policy and Product Portfolio Reference Guide - the agent routes all compliance and product questions to this tool rather than answering from memory, ensuring responses are grounded in approved documentation
- Channel name resolution is handled in the agent prompt via an explicit mapping table - natural language references such as "face to face visit" or "in person" are mapped to `rep_visit` before any tool is called