Skip to content

Iris: Enable autonomous responses#402

Open
toukhi wants to merge 11 commits intomainfrom
iris/feature/enable-autonomous-responses
Open

Iris: Enable autonomous responses#402
toukhi wants to merge 11 commits intomainfrom
iris/feature/enable-autonomous-responses

Conversation

@toukhi
Copy link
Contributor

@toukhi toukhi commented Jan 27, 2026

Summary

This PR introduces the Autonomous Tutor Pipeline, a new pipeline that enables Iris to autonomously respond to student posts in course channels without requiring a human tutor in the loop. The pipeline analyzes student questions and generates helpful, pedagogically sound responses based on available course context (exercises, lectures, FAQs).

Testing the Autonomous Tutor Pipeline

  1. Start Iris locally
  2. Import the Postman collection: Iris – Autonomous Tutor.postman_collection.json
  3. In the imported collection, send one of the included POST requests. Ensure that a valid bearer token is set in the Authorization header.
  4. Check the Iris logs for the generated response

Note: The endpoint returns 202 Accepted immediately.
The actual response is logged and would normally be sent to Artemis via callback.

Summary by CodeRabbit

Release Notes

  • New Features

    • Introduced an autonomous tutor pipeline with intelligent response generation for course discussions
    • Integrated support for accessing course resources including lectures, FAQs, and exercise details
    • Added confidence scoring and direct-posting decision capability for tutor responses
    • New API endpoint to run the autonomous tutor feature
  • Refactoring

    • Consolidated discussion formatting logic into shared utilities for code reuse

✏️ Tip: You can customize this high-level summary in your review settings.

Summary by CodeRabbit

  • New Features

    • Added autonomous tutor pipeline enabling AI-powered student support for course discussions and exercises with configurable model variants
    • Introduced new endpoint to run autonomous tutoring sessions with confidence scoring and direct posting capabilities
    • Added support for lecture and FAQ retrieval tools within tutoring interactions
  • Refactor

    • Consolidated post discussion formatting logic into shared utilities for reusability across pipelines

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 27, 2026

📝 Walkthrough

Walkthrough

Adds an Autonomous Tutor feature: DTOs, a pipeline implementation with prompt/template and tool orchestration, a variant, shared discussion formatting util, web endpoints and callbacks, and status update extensions to carry confidence and posting metadata.

Changes

Cohort / File(s) Summary
Domain DTOs
iris/src/iris/domain/autonomous_tutor/autonomous_tutor_pipeline_execution_dto.py, iris/src/iris/domain/autonomous_tutor/autonomous_tutor_pipeline_status_update_dto.py
Added AutonomousTutorPipelineExecutionDto (course, post, user, optional programming/text exercise and lecture with aliases) and AutonomousTutorPipelineStatusUpdateDTO (result, should_post_directly alias shouldPostDirectly, confidence).
Variant & Pipeline
iris/src/iris/domain/variant/autonomous_tutor_variant.py, iris/src/iris/pipeline/autonomous_tutor_pipeline.py
Added AutonomousTutorVariant and a new AutonomousTutorPipeline (prompt/template rendering, get_tools orchestration, memiris hooks, execution lifecycle, post_agent_hook, confidence estimation, variants listing).
Prompt template
iris/src/iris/pipeline/prompts/templates/autonomous_tutor_system_prompt.j2
New Jinja2 system prompt template defining tutoring rules, conditional context blocks (exercises, lectures, FAQs), and tool usage guidance.
Shared utils & refactor
iris/src/iris/pipeline/shared/utils.py, iris/src/iris/pipeline/tutor_suggestion_pipeline.py
Added format_post_discussion(post: PostDTO, include_user_ids: bool=False) -> str; replaced TutorSuggestionPipeline's private discussion builder with this utility and removed duplicate logic.
Web integration & status
iris/src/iris/web/routers/pipelines.py, iris/src/iris/web/status/status_update.py
Added HTTP endpoint /autonomous-tutor/run and background worker run_autonomous_tutor_pipeline_worker; wired AutonomousTutorPipeline and AutonomousTutorPipelineExecutionDto. Extended StatusCallback.done(...) signature with confidence and should_post_directly; added AutonomousTutorCallback (appears duplicated in file).

Sequence Diagram

sequenceDiagram
    participant Client as Client
    participant Router as HTTP Router
    participant Worker as Background Worker
    participant Pipeline as AutonomousTutorPipeline
    participant Agent as Agent Executor
    participant Tools as Tool Orchestrator
    participant Status as Status Callback

    Client->>Router: POST /autonomous-tutor/run (DTO, variant)
    Router->>Router: Validate DTO & variant
    Router->>Worker: Spawn background execution

    Worker->>Pipeline: start(dto, variant, callback)
    Pipeline->>Pipeline: build_system_message(dto, state)
    Pipeline->>Tools: get_tools(state)
    Tools-->>Pipeline: tool callables (lecture/FAQ/exercise, course details)

    Pipeline->>Agent: Execute agent (system prompt + tools + discussion)
    Agent->>Tools: invoke tools as needed
    Tools-->>Agent: return tool results
    Agent-->>Pipeline: agent response

    Pipeline->>Pipeline: post_agent_hook(response)
    Pipeline->>Pipeline: _estimate_confidence(response)
    Pipeline->>Status: done(result, confidence, should_post_directly)
    Status-->>Client: status updates (via callbacks/webhooks)
    Worker-->>Router: completion logged
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Poem

🐰 I hopped in with prompts and a helpful cue,
Tools at the ready, lecture links in view,
I formatted the chat, estimated a score,
Sent statuses onward and opened the door,
A tutor that learns — let curiosity stew!

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Iris: Enable autonomous responses' directly reflects the main objective of the PR—introducing the Autonomous Tutor Pipeline to enable Iris to autonomously respond to student posts without human intervention.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch iris/feature/enable-autonomous-responses

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 Pylint (4.0.4)
iris/src/iris/web/status/status_update.py
iris/src/iris/pipeline/autonomous_tutor_pipeline.py

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@toukhi toukhi marked this pull request as ready for review February 1, 2026 01:32
@toukhi toukhi requested a review from a team as a code owner February 1, 2026 01:32
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🤖 Fix all issues with AI agents
In `@iris/src/iris/pipeline/autonomous_tutor_pipeline.py`:
- Around line 203-244: The placeholder _estimate_confidence always returns 0.99
which permanently sets should_post_directly true; change _estimate_confidence in
AutonomousTutorPipeline (or wiring around post_agent_hook) to return a
conservative default (e.g., 0.75) or read a configurable default (env/config
flag) so outputs fall into verification by default until a real estimator
exists; update any references to DIRECT_POST_CONFIDENCE_THRESHOLD usage if
needed and add a short debug/warning log in _estimate_confidence indicating the
value is a conservative placeholder.

In `@iris/src/iris/pipeline/prompts/templates/autonomous_tutor_system_prompt.j2`:
- Around line 53-56: In the conditional block controlled by allow_faq_tool in
autonomous_tutor_system_prompt.j2, fix the minor punctuation typo by removing
the extra period at the end of the second sentence ("Respond concisely using the
most relevant FAQ, and only if no other tool fits..") so it ends with a single
period; update the template text within the allow_faq_tool branch accordingly.

In `@iris/src/iris/web/status/status_update.py`:
- Around line 163-166: The code unconditionally assigns should_post_directly to
self.status which can set a non-optional bool to None; update the assignment in
the method that uses self.status (status_update.py) so you only set
self.status.should_post_directly when the caller provided a value (e.g., check
should_post_directly is not None before assigning) while still keeping the
hasattr(self.status, "should_post_directly") guard; make the same conditional
assignment pattern for confidence if needed (check confidence is not None before
assigning to self.status.confidence).
🧹 Nitpick comments (1)
iris/src/iris/domain/variant/autonomous_tutor_variant.py (1)

21-22: Optional: drop redundant required_models override.
AbstractAgentVariant.required_models() already returns {self.agent_model}, so this override is duplicative.

♻️ Suggested cleanup
-    def required_models(self) -> set[str]:
-        return {self.agent_model}

Copy link
Contributor

@florian-glombik florian-glombik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change requests

  • Fix the DTO naming inconsistency
  • Define constant as variable

Other comments

Other comments might not need a change

has_discussion = post.answers and len(post.answers) > 0

template_context = {
"current_date": datetime.now(tz=pytz.UTC).strftime("%Y-%m-%d %H:%M:%S"),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have the timeformatting at multiple places in the code, could we define it as one shared constant instead across the iris code?

Comment on lines +210 to +213
# TODO: Extract confidence from model output or implement confidence estimation
# For now, use a placeholder confidence value
confidence = self._estimate_confidence(state)
should_post_directly = confidence >= self.DIRECT_POST_CONFIDENCE_THRESHOLD
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a TODO for a future PR? Could we link the respective issue then (e.g. on linear)

variant_id="default",
name="Default",
description="Default autonomous tutor variant using the OpenAI GPT-OSS 20B model.",
agent_model="gpt-oss:20b",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it really intended to hardcode the model? Shouldn't we make this configurable?

stage = len(stages)
stages += [
StageDTO(
weight=30,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we define the 30 as constant and describe why we choose 30 and not some other value?

from iris.domain.pipeline_execution_dto import PipelineExecutionDTO


class AutonomousTutorPipelineExecutionDto(PipelineExecutionDTO):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We usually capatalize DTO

Suggested change
class AutonomousTutorPipelineExecutionDto(PipelineExecutionDTO):
class AutonomousTutorPipelineExecutionDTO(PipelineExecutionDTO):

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants