Skip to main content

HANI2

HANI2 is a web interface for human–agent negotiation studies. People negotiate in the browser against automated agents built with negmas, optionally helped by an AI Assistant, while HANI2 records every offer, message, click and questionnaire answer. It runs the human–agent negotiation and hybrid intelligence tracks of the ANAC competition.

HANI2 is a Python package: a FastAPI backend plus a React frontend that ships pre-built inside the wheel.

Documentation: https://autoneg.github.io/hani2/

Install and run

Requires Python 3.11 or newer (tested up to 3.15).

pip install hani2
hani2 setup      # creates ~/negmas/hani2/settings with defaults, users and sample scenarios
hani2            # http://localhost:5006

One port (default 5006) serves:

URL What
/app The negotiation interface for logged-in users (user / userpass, admin / adminpass).
/play The no-login playground. Prolific participants arrive at /play?PROLIFIC_PID=....
/admin The admin console.
/api The REST and WebSocket API.

The Assistant and LLM opponents need a language model. The defaults use a local Ollama model:

ollama pull qwen3:4b-instruct

Any provider supported by litellm works too; see Language models.

Features

  • Negotiation desk: the opponent's offer on the table, a counter-offer editor, utility gauges with a no-deal marker, a conversation-style history, confirmation before accepting or ending, three layouts and a phone layout.
  • Tools: preferences, plots, histograms, the offer trace, an offer picker and more, in panes participants can rearrange. Write new ones in Python.
  • Assistant: an AI helper that chats, highlights and annotates the interface, rearranges tools, shows interactive panels and, with permission, makes offers. It can also find, use and add tools. Sixteen capabilities and three autonomy levels.
  • Autopilot: the Assistant or any negotiator plays the human's seat.
  • WebMCP: browser AI agents can read and (optionally) negotiate through the page's tools.
  • Opponents: any negmas, Genius or negmas-llm negotiator, your own classes, and named groups.
  • Studies: self-contained experiments, questionnaires, results CSV files and an event log with analytics.
  • Prolific: practice rounds, counted rounds and completion links.
  • Admin console: live sessions, results, analytics, users and all settings in the browser.
  • Accounts: password, GitHub and Google OAuth, or no login; optional consent form.

A custom opponent agent

The opponent is any negmas SAONegotiator. This one concedes over time and says why; text in the data of an offer shows in the participant's history.

# my_opponent.py
from negmas.outcomes import ExtendedOutcome
from negmas.sao import ResponseType, SAONegotiator


class Haggler(SAONegotiator):
    """Asks for a lot at first, concedes linearly over time, and explains itself."""

    def target(self, state) -> float:
        lo, hi = self.ufun.minmax()
        floor = max(lo, float(self.ufun.reserved_value or lo))
        return hi - state.relative_time * (hi - floor) * 0.8  # never concede the last 20%

    def propose(self, state, dest=None):
        outcome = self.ufun.invert().one_in((self.target(state), self.ufun.max()), normalized=False)
        text = "This is my best offer." if state.relative_time < 0.5 else "I am meeting you halfway now."
        return ExtendedOutcome(outcome, data={"text": text})

    def respond(self, state, source=None):
        offer = state.current_offer
        if offer is not None and self.ufun(offer) >= self.target(state):
            return ResponseType.ACCEPT_OFFER
        return ResponseType.REJECT_OFFER

Start the server from the folder that holds my_opponent.py:

hani2 --opponents file:my_opponent.Haggler

Or list it in opponents in env.json, next to built-in agents and groups such as :template or helpers.AgentK. See Opponents.

A custom Assistant

# my_agent.py
from hani2.assistant.runtime import Assistant


class RulesAgent(Assistant):
    def handle_user_message(self, text: str) -> None:
        actions = self.session_state.get("actions")
        if not actions:
            self.post("Load a scenario and start a negotiation first.")
            return
        ctx = self.run_on_doc(actions["context"])
        if ctx["partner_offer"] is None:
            self.post("Your opponent has not made an offer yet.")
        elif ctx["partner_offer_utility"] < ctx["reserved_value"]:
            self.post("That offer is worse than walking away.")
        else:
            self.post("That offer beats your reserved value.")

Point agent_class in ~/negmas/hani2/settings/assistant_settings.json at it and start the server from the folder that holds my_agent.py:

{"agent_class": "my_agent:RulesAgent"}
PYTHONPATH=$PWD hani2 --page play

The Assistant tutorial goes from this to LLM agents that highlight the interface and show their own panels.

A custom tool

# my_tools.py
from hani2.tools import Tool, ui


class OfferCounter(Tool):
    name = "Offer Counter"
    description = "How many offers each side made so far."
    icon = "hash"
    pane = "side"

    def view(self):
        trace = self.trace()
        me = self.session_state.get("human_id")
        mine = sum(1 for row in trace if row[3] == me)
        return [ui.stats(ui.stat("Your offers", mine), ui.stat("Opponent offers", len(trace) - mine))]

Register it in ~/negmas/hani2/settings/env.json:

{"tools": {"extra": ["my_tools:OfferCounter"]}}

See the tools tutorial.

Development

git clone https://github.com/autoneg/hani2
cd hani2
uv venv
uv pip install -e '.[dev]'
pytest

# the web app (writes the bundle to src/hani2/web)
cd frontend
npm install
npm run build

For frontend work, run hani2 --no-browser --dev and npm run dev in frontend/ (port 5173, proxied to the backend). To build the documentation, install .[docs] and run mkdocs serve.

License

AGPL-3.0-or-later. See LICENSE.

Metadata

Release files for hani2 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for hani2 0.2.0
File Size Uploaded Provenance Actions
hani2-0.2.0.tar.gz 6.9 MB With provenance Details for hani2-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for hani2 0.2.0
File Interpreter ABI Platform Actions
hani2-0.2.0-py3-none-any.whl Python 3 none any Details for hani2-0.2.0-py3-none-any.whl

Total release size: 11.3 MB

Release files / hani2-0.2.0.tar.gz

Download URL hani2-0.2.0.tar.gz
Size 6.9 MB
Tags Source
SHA-256 checksum
How to use checksums
fd72a6040b27b4ee87f1f5dc15220da4e5c3c26bc31a44bae1d6df309f8e3a91
BLAKE2b-256 checksum
How to use checksums
7e922d3d064be50d009e0b9c0c54003f8f7a4f024f859b589e222336a47dcb53
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 20, 2026.

Transparency log

Release files / hani2-0.2.0-py3-none-any.whl

Download URL hani2-0.2.0-py3-none-any.whl
Size 4.4 MB
Tags Python 3
SHA-256 checksum
How to use checksums
3ac0e6fdd57949216d45f3ac11df56dd21d9d9963a821ace6641637a96401062
BLAKE2b-256 checksum
How to use checksums
b02fb3723cf682b7be30cd7c3212d0254556bd9f83c50630e3698369f9bbe58d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 20, 2026.

Transparency log

Security for hani2 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for hani2-0.2.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 20, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page