CoolFace
Apppublic

ihere04u/business-strategy-env

sourceHugging Faceupdated 6mo agoView on Hugging Face
1likes
App README

🏒 Business Strategy Simulation Environment

An OpenEnv-compliant real-world environment where an AI agent acts as CEO, making quarterly strategic decisions to grow a company. Features stochastic market dynamics and multi-objective reward optimization.

Built for the OpenEnv Hackathon β€” Round 1 Β· Live API Docs


🌍 Why This Environment?

Business strategy is a genuine real-world task β€” companies live and die by quarterly decisions on hiring, marketing, pricing, and R&D. This environment models those decisions with:

  • β€”Stochastic market dynamics β€” random noise simulates real market unpredictability
  • β€”Interdependent state variables β€” actions have cascading effects (e.g. cutting costs reduces quality, reducing satisfaction, reducing market share)
  • β€”Multi-objective trade-offs β€” agents must balance short-term profit vs long-term growth
  • β€”Partial progress rewards β€” dense reward signal every quarter, not just at episode end

🎯 Tasks

TaskDifficultyGoalMax QuartersReward Formula
surviveEasyKeep profit > 0 every quarter4profitable_quarters / total_quarters
grow_market_shareMediumReach 20% market share8min(market_share / 0.20, 1.0) + early bonus
scale_profitablyHard2x revenue AND satisfaction β‰₯ 0.8120.6 Γ— revenue_score + 0.4 Γ— satisfaction_score

πŸ”§ Action Space

10 strategic actions, each with an optional amount parameter (default: $5,000):

ActionPrimary Effect
increase_marketing↑ Market share, ↑ Satisfaction, ↑ Costs
decrease_marketing↓ Costs, ↓ Market share
hire_employees↑ Revenue capacity, ↑ Costs
layoff_employees↓ Costs, ↓ Satisfaction
cut_costs↓ Costs, ↓ Product quality
invest_in_rd↑ Product quality, ↑ Costs
launch_product↑ Revenue, ↑ Market share
expand_market↑ Market share, ↑ Revenue
raise_prices↑ Revenue, ↓ Satisfaction, ↓ Market share
lower_prices↓ Revenue, ↑ Satisfaction, ↑ Market share

πŸ‘οΈ Observation Space

This environment returns both raw business metrics and higher-level strategy signals.

json
{
  "revenue": 50000.0,
  "costs": 35000.0,
  "profit": 15000.0,
  "market_share": 0.10,
  "employees": 20,
  "customer_satisfaction": 0.70,
  "marketing_budget": 5000.0,
  "rd_investment": 2000.0,
  "product_quality": 0.65,
  "profit_margin": 0.30,
  "cost_efficiency": 0.30,
  "growth_signal": 0.40,
  "profit_trend": 0.0,
  "last_reward": 0.0,
  "risk_level": 0.70,
  "strategic_health": 0.37,
  "growth_momentum": 0.07,
  "decision_quality": "neutral",
  "quarter": 1,
  "max_quarters": 4,
  "done": false,
  "reward": 0.0,
  "message": "Q1: Profit=$15,000 | Market=10.0%"
}

πŸ“‘ API Endpoints

MethodEndpointDescription
GET/healthHealth check β€” returns {"status": "healthy"}
GET/metadataEnvironment metadata
GET/schemaTyped action/observation/state schemas
POST/resetReset environment for a task
POST/stepTake an action, advance one quarter
GET/stateGet current state
GET/tasksList all tasks + action schema
POST/graderGrade a completed episode
GET/baselineRun rule-based baseline on all 3 tasks
POST/mcpMCP JSON-RPC endpoint

πŸ† Reward Design

All rewards are partial progress signals β€” no sparse binary end-of-episode rewards:

  • β€”survive: profitable_quarters / total_quarters β€” scores every quarter
  • β€”grow_market_share: min(final_share / 0.20, 1.0) + early completion bonus
  • β€”scale_profitably: 0.6 Γ— revenue_score + 0.4 Γ— satisfaction_score β€” weighted multi-objective

Undesirable behaviors are penalized:

  • β€”Bankruptcy (profit < -$50,000) β†’ early termination
  • β€”Over-hiring with no revenue β†’ costs spiral punishes poor decisions
  • β€”Cutting costs repeatedly β†’ product quality degrades, reducing future revenue

🧠 Advanced Learning Dynamics

This environment is intentionally designed to challenge decision-making agents through:

1. Multi-Objective Optimization

Agents must balance:

  • β€”Profitability
  • β€”Market share growth
  • β€”Customer satisfaction
  • β€”Cost efficiency

2. Delayed Rewards

Investments in R&D improve future revenue rather than immediate outcomes.

3. Strategic Trade-offs

Each action has both positive and negative consequences:

  • β€”Expanding markets increases growth but reduces satisfaction
  • β€”Cost cutting improves margins but degrades product quality

4. Stochastic Environment

  • β€”Economic cycles affect revenue unpredictably
  • β€”Competitor pressure reduces market share dynamically

5. Non-Linear Reward Shaping

Rewards include:

  • β€”Trend-based bonuses
  • β€”Strategic diversity incentives
  • β€”Penalties for repetitive or short-sighted decisions

6. Failure Cascades

Poor decisions (e.g., low satisfaction) trigger compounding negative effects.

7. Decision Feedback

The environment exposes decision quality signals such as decision_quality and a final_summary at episode end.

This creates a realistic environment requiring long-term planning, adaptation, and strategic reasoning.


πŸ“Š Baseline Scores

Scores from the included rule-based baseline agent (baseline.py):

TaskScoreNotes
survive0.999Profitable all 4 quarters
grow_market_share0.685Explores aggressively, but market share remains a challenge
scale_profitably0.999Revenue target reached with tight satisfaction
Note: Baseline performance is intentionally stochastic and may vary across seeds.

πŸ€– Agent Strategy

The included rule-based inference agent (inference.py) uses adaptive task-specific logic:

  • β€”Survive: Maintains profitability by cutting costs when needed, then rotates between growth actions
  • β€”Grow Market Share: Progressively increases market reachβ€”expands when low, invests in marketing, then launches products
  • β€”Scale Profitably: Balances quality, satisfaction, and growthβ€”invests heavily in R&D, then scales with pricing and expansion

The agent includes anti-repetition safety to avoid over-using the same action, ensuring diverse strategy execution. The agent is fully rule-based and does not depend on external LLM calls, ensuring stable and deterministic performance. ---

πŸš€ Setup & Run

Local

bash
pip install -r requirements.txt
python baseline.py      # verify logic
python server.py        # start API server

Visit: http://localhost:7860/docs

Local app entrypoint

bash
python main.py

Docker

bash
docker build -t business-strategy-env .
docker run -p 7860:7860 business-strategy-env

Inference (Rule-Based Agent)

bash
python inference.py

πŸ“‹ Quick Example

python
import requests

BASE = "https://ihere04u-business-strategy-env.hf.space"

# Reset
state = requests.post(f"{BASE}/reset", json={"task": "survive", "seed": 42}).json()

# Play 4 quarters
for _ in range(4):
    state = requests.post(f"{BASE}/step", json={
        "task": "survive",
        "action": "increase_marketing",
        "amount": 5000
    }).json()
    print(state["message"], "| Reward:", state["reward"])

# Grade
score = requests.post(f"{BASE}/grader", json={"task": "survive"}).json()
print("Final score:", score["score"])

πŸ“ Project Structure

business-strategy-env/
β”œβ”€β”€ environment.py     # Core simulation logic + stochastic market dynamics
β”œβ”€β”€ graders.py         # Task-specific graders returning scores in [0.0, 1.0]
β”œβ”€β”€ server.py          # FastAPI server β€” all OpenEnv + additional endpoints
β”œβ”€β”€ baseline.py        # Rule-based baseline agent
β”œβ”€β”€ inference.py       # LLM agent using OpenAI-compatible client
β”œβ”€β”€ openenv.yaml       # OpenEnv spec
β”œβ”€β”€ Dockerfile         # Container β€” deploys on HF Spaces (port 7860)
β”œβ”€β”€ requirements.txt
└── README.md