Adding AI Code Detection to a MOSS Plagiarism Workflow

Many CS departments have run MOSS after every programming deadline for years: a TA uploads the submissions, reviews the highest-similarity pairs, and brings clear cases of peer copying to the integrity board. That workflow still works for what it was designed to catch. What it cannot do is flag a student who submitted code generated by a large language model.

The fix is not to throw MOSS away. It is to combine similarity checking with AI-specific scoring and web-source lookups, so that no single signal has to carry the burden of proof alone. This guide walks through how to do that.

The Detection Gap

The pattern instructors describe is consistent. Code comes in clean and idiomatic, with comments and error handling that first-year students rarely include. MOSS shows no meaningful matches against other submissions. Yet the code feels off: mechanically fluent, without the mistakes and personal touches instructors learn to expect.

Instructors can often smell it, but MOSS doesn't have a nose. Without tool-based evidence, cases cannot be filed, and students learn that saying "I swear I wrote it" is enough to make an instructor back off.

Consider a suspiciously perfect recursive backtracking solution appearing in three different sections within the same hour. Each submission has different variable names (one uses currentIdx, another pos, a third pointer), but the algorithmic structure is identical down to the ordering of edge-case checks. MOSS can still give a pair like that a noise-level similarity score, which leaves instructors flying blind.

Why MOSS Is Not Enough on Its Own

MOSS excels at finding large blocks of copied code between submissions because it normalizes whitespace, variable names, and some control structures before comparing token fingerprints. That strength is also its blind spot for AI-generated code. When a model produces code for each student separately, even from similar prompts, the token sequences often vary enough to fall below MOSS's thresholds. And because MOSS compares submissions to each other, it has no way to analyze the statistical texture of a single file and ask whether a human wrote it.

Validate Before You Switch

Before changing a grading workflow, run a small comparison on your own material. Take a set of assignments you know were written by people (for example, from before AI assistants were common) and a set you strongly suspect were generated, and run both through the tools you are considering:

  • MOSS with peer-to-peer comparison only. Watch for flags that are coincidental rather than structurally related to the suspected AI use.
  • JPlag (token-based). Robust to renaming, but like MOSS it gives no per-file judgment about whether code was machine-written.
  • A combined pipeline (similarity, web, and AI detection). Check how many suspected files it labels as likely AI, and, just as important, how many of your known-human files it wrongly flags.

The known-human set is the part people skip, and it is the part that tells you whether a threshold is safe to use.

Running AI Detection Alongside Plagiarism Checking

The integration can be script-driven. If your LMS (Canvas, for example) exports submissions as zip archives, a short Python script can push each archive to Codequiry's REST API, create a check, upload all submissions, and trigger a scan. The structured JSON report (similarity pairs, web source URLs, and per-file AI probability scores) can then be flattened into a CSV for the TA review queue.

Keep the old MOSS run going for a few assignments to compare outputs. Expect the AI-specific detections to overlap very little with MOSS's high-similarity pairs, because the two are answering different questions.

Codequiry dashboard home with recent checks showing peer, web and AI similarity scores
The Codequiry dashboard: recent checks at a glance with peer, web and AI similarity scores.

In the Codequiry dashboard, submissions can be sorted by a combined risk view of similarity, web matches, and AI probability. Each flagged submission can be expanded to show:

  • The top matching peer submissions, with a side-by-side diff
  • Any matching web sources, such as Stack Overflow excerpts or GitHub copies
  • The AI detection score and the signals contributing to it
  • The specific blocks most indicative of machine origin
Codequiry AI code detection report with average and highest AI probability and a risk distribution
AI-code detection: probability scores per file, flagging submissions likely written by ChatGPT, Copilot, Claude or Gemini.

What to Watch For in AI-Flagged Submissions

  • Pressure points in the term. Look closely at final projects and labs due during crunch weeks.
  • Submission timing. Late-night submissions are not evidence on their own, but they are worth noting alongside other signals.
  • Comment style. Generated code often uses complete-sentence comments in an explanatory voice ("We create a temporary buffer to hold..."), unlike typical first-year shorthand ("// buffer for temp vals").

Correlating AI Flags With Web-Source Matches

One of the most useful workflows is layering the AI score with web-source findings. A common pattern: a student finds a Stack Overflow or GitHub snippet, feeds it to an LLM, and asks it to rename variables and add comments. The result is structurally close to the web source but textually different enough to evade a pure fingerprint check.

For example, picture a Java method for balancing an AVL tree that traces back to a popular tutorial example. The student ran it through ChatGPT with the prompt "rewrite this code but change all variable names and add detailed comments." A token-based diff shows only modest similarity to the original. But the AI code detector scores the file high, and the web-source match confirms where the logic came from.

Codequiry web results tracing copied code to GitHub, Stack Overflow and the open web
Web results: Codequiry traces copied code back to GitHub, Stack Overflow and the open web.

That combination creates a provenance chain: the web source shows where the logic came from, and the AI score shows that an LLM was used to disguise it. Neither signal alone would be conclusive at most honor boards; together, they leave little room for dispute.

Thresholds and Student Communication

Tell students on day one that all code submissions will be scanned for plagiarism and AI generation. A first-week lecture on academic integrity can show anonymized flagged snippets and the signals the tool uses. Visible detection tends to change behavior early in the term.

Do not chase every AI signal. Tune the thresholds so that only submissions with a high AI score and at least one corroborating signal (a web match, unusual submission patterns, or peer-similarity overlap) go to formal review, and check that setting against your known-human set. Every flagged case still gets human review: look at the code, look at the student's history, talk to the student. The report is a place to start.

Lessons for CS Departments

  1. Don't rely on a single signal. Pure AI detectors generate false positives and miss hybrid code. Combining similarity, web, and AI checks gives you corroborating evidence that holds up in front of a committee.
  2. Automate the scan into your existing pipeline. An API integration replaces hours of hand-reviewing suspect pairs with a short scripted step per assignment.
  3. Use the results as a teaching tool. Showing students what gets flagged and why reduces cheating before it happens.
  4. Set realistic thresholds. Flag every submission with a middling AI score and you will drown in false positives. Require a high score plus corroboration.
  5. Keep MOSS (or an equivalent) for peer-to-peer baselines, but don't expect it to solve the AI problem. The tools serve different functions.

For departments that want all of this without stitching together several open-source projects, a code plagiarism checker with integrated AI detection is the simplest path. The API makes it straightforward to embed into existing LMS workflows, and the layered report means TAs are not left guessing which signal to trust.

Frequently Asked Questions

Can MOSS detect AI-generated code?

No. MOSS compares token fingerprints between submissions, but it has no mechanism to judge whether a single file was written by a human or an LLM. AI code generated separately for each student rarely triggers MOSS because the token sequences vary too much.

What false-positive rate should I expect from AI code detection?

Measure it yourself on code you know was written by people in your own course, at the threshold you plan to use. Treat any AI detector as a flagging tool, not a final verdict; human review remains essential.

How does combining AI detection with web-source checking help integrity cases?

When AI-generated code is based on a public snippet that was then masked, the web match provides the origin and the AI score explains the disguise. Together they form a chain of evidence that is harder to deny than a single metric.

Can detectors tell AI-assisted code from fully AI-generated code?

Current detectors can identify blocks that are statistically likely to be machine-generated, but distinguishing "student wrote the skeleton, AI filled in the methods" from "AI wrote everything" is still a research problem. Mixed submissions tend to get lower-confidence scores, which is a cue for a reviewer to look for partial use.

For any CS department trying to close the gap between human copying and machine-generated submissions, a multi-signal approach is the clearest path forward. Learn how an integrated AI code detector and plagiarism checker can work in your courses.